Skip to content

Commit f9ebce5

Browse files
daholsteDmitry-A
authored andcommitted
[AutoML] Enable style cop rules & resolve errors (dotnet#3823)
1 parent e5ebbf5 commit f9ebce5

File tree

84 files changed

+1144
-1046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1144
-1046
lines changed

Microsoft.ML.AutoML.sln

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mlnet.Tests", "test\mlnet.T
1212
EndProject
1313
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.AutoML.Samples", "docs\samples\Microsoft.ML.AutoML.Samples\Microsoft.ML.AutoML.Samples.csproj", "{6E84E7C5-FECE-45A9-AD4C-4B0F39F78904}"
1414
EndProject
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.InternalCodeAnalyzer", "tools-local\Microsoft.ML.InternalCodeAnalyzer\Microsoft.ML.InternalCodeAnalyzer.csproj", "{954F14B0-BBDF-4A30-811E-2D86FDB5B399}"
16+
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools-local", "tools-local", "{2DEB692B-D982-4301-A074-DAA095658230}"
18+
EndProject
1519
Global
1620
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1721
Debug|Any CPU = Debug|Any CPU
@@ -82,10 +86,25 @@ Global
8286
{6E84E7C5-FECE-45A9-AD4C-4B0F39F78904}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
8387
{6E84E7C5-FECE-45A9-AD4C-4B0F39F78904}.Release-netfx|Any CPU.ActiveCfg = Release-netfx|Any CPU
8488
{6E84E7C5-FECE-45A9-AD4C-4B0F39F78904}.Release-netfx|Any CPU.Build.0 = Release-netfx|Any CPU
89+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
90+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Debug|Any CPU.Build.0 = Debug|Any CPU
91+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU
92+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU
93+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Debug-netfx|Any CPU.ActiveCfg = Debug-netfx|Any CPU
94+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Debug-netfx|Any CPU.Build.0 = Debug-netfx|Any CPU
95+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Release|Any CPU.ActiveCfg = Release|Any CPU
96+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Release|Any CPU.Build.0 = Release|Any CPU
97+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU
98+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
99+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Release-netfx|Any CPU.ActiveCfg = Release-netfx|Any CPU
100+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399}.Release-netfx|Any CPU.Build.0 = Release-netfx|Any CPU
85101
EndGlobalSection
86102
GlobalSection(SolutionProperties) = preSolution
87103
HideSolutionNode = FALSE
88104
EndGlobalSection
105+
GlobalSection(NestedProjects) = preSolution
106+
{954F14B0-BBDF-4A30-811E-2D86FDB5B399} = {2DEB692B-D982-4301-A074-DAA095658230}
107+
EndGlobalSection
89108
GlobalSection(ExtensibilityGlobals) = postSolution
90109
SolutionGuid = {8C1BC26C-B87E-47CD-928E-00EFE4353B40}
91110
EndGlobalSection

src/Microsoft.ML.AutoML/API/AutoCatalog.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ internal AutoCatalog(MLContext context)
2727
/// <para>See <see cref="RegressionExperiment"/> for a more detailed code example of an AutoML regression experiment.</para>
2828
/// <para>An experiment may run for longer than <paramref name="maxExperimentTimeInSeconds"/>.
2929
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
30-
/// model train to completion. For instance, if the first model
30+
/// model train to completion. For instance, if the first model
3131
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
32-
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
32+
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
3333
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).</para>
3434
/// </remarks>
3535
public RegressionExperiment CreateRegressionExperiment(uint maxExperimentTimeInSeconds)
@@ -62,9 +62,9 @@ public RegressionExperiment CreateRegressionExperiment(RegressionExperimentSetti
6262
/// <para>See <see cref="BinaryClassificationExperiment"/> for a more detailed code example of an AutoML binary classification experiment.</para>
6363
/// <para>An experiment may run for longer than <paramref name="maxExperimentTimeInSeconds"/>.
6464
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
65-
/// model train to completion. For instance, if the first model
65+
/// model train to completion. For instance, if the first model
6666
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
67-
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
67+
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
6868
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).</para>
6969
/// </remarks>
7070
public BinaryClassificationExperiment CreateBinaryClassificationExperiment(uint maxExperimentTimeInSeconds)
@@ -97,9 +97,9 @@ public BinaryClassificationExperiment CreateBinaryClassificationExperiment(Binar
9797
/// <para>See <see cref="MulticlassClassificationExperiment"/> for a more detailed code example of an AutoML multiclass classification experiment.</para>
9898
/// <para>An experiment may run for longer than <paramref name="maxExperimentTimeInSeconds"/>.
9999
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
100-
/// model train to completion. For instance, if the first model
100+
/// model train to completion. For instance, if the first model
101101
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
102-
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
102+
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
103103
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).</para>
104104
/// </remarks>
105105
public MulticlassClassificationExperiment CreateMulticlassClassificationExperiment(uint maxExperimentTimeInSeconds)
@@ -136,15 +136,15 @@ public MulticlassClassificationExperiment CreateMulticlassClassificationExperime
136136
/// <returns>Information inferred about the columns in the provided dataset.</returns>
137137
/// <remarks>
138138
/// Infers information about the name, data type, and purpose of each column.
139-
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
140-
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
141-
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
139+
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
140+
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
141+
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
142142
/// or used elsewhere in the ML.NET ecosystem (ie in <see cref="IEstimator{TTransformer}.Fit(IDataView)"/>.
143143
/// The <see cref="ColumnInformation"/> contains the inferred purpose of each column in the dataset.
144144
/// (For instance, is the column categorical, numeric, or text data? Should the column be ignored? Etc.)
145145
/// The <see cref="ColumnInformation"/> can be inspected and modified (or kept as is) and used by an AutoML experiment.
146146
/// </remarks>
147-
public ColumnInferenceResults InferColumns(string path, string labelColumnName = DefaultColumnNames.Label, char? separatorChar = null, bool? allowQuoting = null,
147+
public ColumnInferenceResults InferColumns(string path, string labelColumnName = DefaultColumnNames.Label, char? separatorChar = null, bool? allowQuoting = null,
148148
bool? allowSparse = null, bool trimWhitespace = false, bool groupColumns = true)
149149
{
150150
UserInputValidationUtil.ValidateInferColumnsArgs(path, labelColumnName);
@@ -164,9 +164,9 @@ public ColumnInferenceResults InferColumns(string path, string labelColumnName =
164164
/// <returns>Information inferred about the columns in the provided dataset.</returns>
165165
/// <remarks>
166166
/// Infers information about the name, data type, and purpose of each column.
167-
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
168-
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
169-
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
167+
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
168+
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
169+
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
170170
/// or used elsewhere in the ML.NET ecosystem (ie in <see cref="IEstimator{TTransformer}.Fit(IDataView)"/>.
171171
/// The <see cref="ColumnInformation"/> contains the inferred purpose of each column in the dataset.
172172
/// (For instance, is the column categorical, numeric, or text data? Should the column be ignored? Etc.)
@@ -194,15 +194,15 @@ public ColumnInferenceResults InferColumns(string path, ColumnInformation column
194194
/// <returns>Information inferred about the columns in the provided dataset.</returns>
195195
/// <remarks>
196196
/// Infers information about the name, data type, and purpose of each column.
197-
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
198-
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
199-
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
197+
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
198+
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
199+
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
200200
/// or used elsewhere in the ML.NET ecosystem (ie in <see cref="IEstimator{TTransformer}.Fit(IDataView)"/>.
201201
/// The <see cref="ColumnInformation"/> contains the inferred purpose of each column in the dataset.
202202
/// (For instance, is the column categorical, numeric, or text data? Should the column be ignored? Etc.)
203203
/// The <see cref="ColumnInformation"/> can be inspected and modified (or kept as is) and used by an AutoML experiment.
204204
/// </remarks>
205-
public ColumnInferenceResults InferColumns(string path, uint labelColumnIndex, bool hasHeader = false, char? separatorChar = null,
205+
public ColumnInferenceResults InferColumns(string path, uint labelColumnIndex, bool hasHeader = false, char? separatorChar = null,
206206
bool? allowQuoting = null, bool? allowSparse = null, bool trimWhitespace = false, bool groupColumns = true)
207207
{
208208
UserInputValidationUtil.ValidateInferColumnsArgs(path);

src/Microsoft.ML.AutoML/API/BinaryClassificationExperiment.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,30 @@
1313
namespace Microsoft.ML.AutoML
1414
{
1515
/// <summary>
16-
/// Settings for AutoML experiments on binary classification datasets.
16+
/// Settings for AutoML experiments on binary classification datasets.
1717
/// </summary>
1818
public sealed class BinaryExperimentSettings : ExperimentSettings
1919
{
2020
/// <summary>
2121
/// Metric that AutoML will try to optimize over the course of the experiment.
2222
/// </summary>
23-
public BinaryClassificationMetric OptimizingMetric { get; set; } = BinaryClassificationMetric.Accuracy;
23+
/// <value>The default value is <see cref="BinaryClassificationMetric.Accuracy"/>.</value>
24+
public BinaryClassificationMetric OptimizingMetric { get; set; }
2425

2526
/// <summary>
2627
/// Collection of trainers the AutoML experiment can leverage.
2728
/// </summary>
28-
/// <remarks>
29-
/// The collection is auto-populated with all possible trainers (all values of <see cref="BinaryClassificationTrainer" />).
30-
/// </remarks>
31-
public ICollection<BinaryClassificationTrainer> Trainers { get; } =
32-
Enum.GetValues(typeof(BinaryClassificationTrainer)).OfType<BinaryClassificationTrainer>().ToList();
29+
/// <value>The default value is a collection auto-populated with all possible trainers (all values of <see cref="BinaryClassificationTrainer" />).</value>
30+
public ICollection<BinaryClassificationTrainer> Trainers { get; }
31+
32+
/// <summary>
33+
/// Initializes a new instance of <see cref="BinaryExperimentSettings"/>.
34+
/// </summary>
35+
public BinaryExperimentSettings()
36+
{
37+
OptimizingMetric = BinaryClassificationMetric.Accuracy;
38+
Trainers = Enum.GetValues(typeof(BinaryClassificationTrainer)).OfType<BinaryClassificationTrainer>().ToList();
39+
}
3340
}
3441

3542
/// <summary>

src/Microsoft.ML.AutoML/API/ColumnInference.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ public sealed class ColumnInferenceResults
2020
/// Can be used to instantiate a new <see cref="TextLoader" /> to load
2121
/// data into an <see cref="IDataView" />.
2222
/// </remarks>
23-
public TextLoader.Options TextLoaderOptions { get; internal set; } = new TextLoader.Options();
23+
public TextLoader.Options TextLoaderOptions { get; internal set; }
2424

2525
/// <summary>
2626
/// Information about the inferred columns in the dataset.
2727
/// </summary>
2828
/// <remarks>
2929
/// <para>Contains the inferred purposes of each column. See <see cref="AutoML.ColumnInformation"/> for more details.</para>
30-
/// <para>This can be fed to the AutoML API when running an experiment.
30+
/// <para>This can be fed to the AutoML API when running an experiment.
3131
/// See <typeref cref="ExperimentBase{TMetrics, TExperimentSettings}.Execute(IDataView, ColumnInformation, IEstimator{ITransformer}, System.IProgress{RunDetail{TMetrics}})" />
3232
/// for example.</para>
3333
/// </remarks>
34-
public ColumnInformation ColumnInformation { get; internal set; } = new ColumnInformation();
34+
public ColumnInformation ColumnInformation { get; internal set; }
3535
}
3636

3737
/// <summary>
3838
/// Information about the columns in a dataset.
3939
/// </summary>
4040
/// <remarks>
4141
/// <para>Contains information about the purpose of each column in the dataset. For instance,
42-
/// it enumerates the dataset columns that AutoML should treat as categorical,
42+
/// it enumerates the dataset columns that AutoML should treat as categorical,
4343
/// the columns AutoML should ignore, which column is the label, etc.</para>
4444
/// <para><see cref="ColumnInformation"/> can be fed to the AutoML API when running an experiment.
4545
/// See <typeref cref="ExperimentBase{TMetrics, TExperimentSettings}.Execute(IDataView, ColumnInformation, IEstimator{ITransformer}, System.IProgress{RunDetail{TMetrics}})" />
@@ -50,17 +50,18 @@ public sealed class ColumnInformation
5050
/// <summary>
5151
/// The dataset column to use as the label.
5252
/// </summary>
53-
public string LabelColumnName { get; set; } = DefaultColumnNames.Label;
53+
/// <value>The default value is "Label".</value>
54+
public string LabelColumnName { get; set; }
5455

5556
/// <summary>
5657
/// The dataset column to use for example weight.
5758
/// </summary>
5859
public string ExampleWeightColumnName { get; set; }
5960

6061
/// <summary>
61-
/// The dataset column to use for grouping rows.
62+
/// The dataset column to use for grouping rows.
6263
/// If two examples share the same sampling key column name,
63-
/// they are guaranteed to appear in the same subset (train or test).
64+
/// they are guaranteed to appear in the same subset (train or test).
6465
/// This can be used to ensure no label leakage from the train to the test set.
6566
/// If <see langword="null"/>, no row grouping will be performed.
6667
/// </summary>
@@ -69,24 +70,37 @@ public sealed class ColumnInformation
6970
/// <summary>
7071
/// The dataset columns that are categorical.
7172
/// </summary>
73+
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
7274
/// <remarks>
7375
/// Categorical data columns should generally be columns that contain a small number of unique values.
7476
/// </remarks>
75-
public ICollection<string> CategoricalColumnNames { get; } = new Collection<string>();
77+
public ICollection<string> CategoricalColumnNames { get; }
7678

7779
/// <summary>
7880
/// The dataset columns that are numeric.
7981
/// </summary>
80-
public ICollection<string> NumericColumnNames { get; } = new Collection<string>();
82+
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
83+
public ICollection<string> NumericColumnNames { get; }
8184

8285
/// <summary>
8386
/// The dataset columns that are text.
8487
/// </summary>
85-
public ICollection<string> TextColumnNames { get; } = new Collection<string>();
88+
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
89+
public ICollection<string> TextColumnNames { get; }
8690

8791
/// <summary>
8892
/// The dataset columns that AutoML should ignore.
8993
/// </summary>
90-
public ICollection<string> IgnoredColumnNames { get; } = new Collection<string>();
94+
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
95+
public ICollection<string> IgnoredColumnNames { get; }
96+
97+
public ColumnInformation()
98+
{
99+
LabelColumnName = DefaultColumnNames.Label;
100+
CategoricalColumnNames = new Collection<string>();
101+
NumericColumnNames = new Collection<string>();
102+
TextColumnNames = new Collection<string>();
103+
IgnoredColumnNames = new Collection<string>();
104+
}
91105
}
92106
}

0 commit comments

Comments
 (0)