Skip to content

[AutoML] Enable style cop rules & resolve errors #3823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/Microsoft.ML.AutoML/API/AutoCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ internal AutoCatalog(MLContext context)
/// <para>See <see cref="RegressionExperiment"/> for a more detailed code example of an AutoML regression experiment.</para>
/// <para>An experiment may run for longer than <paramref name="maxExperimentTimeInSeconds"/>.
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
/// model train to completion. For instance, if the first model
/// model train to completion. For instance, if the first model
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).</para>
/// </remarks>
public RegressionExperiment CreateRegressionExperiment(uint maxExperimentTimeInSeconds)
Expand Down Expand Up @@ -62,9 +62,9 @@ public RegressionExperiment CreateRegressionExperiment(RegressionExperimentSetti
/// <para>See <see cref="BinaryClassificationExperiment"/> for a more detailed code example of an AutoML binary classification experiment.</para>
/// <para>An experiment may run for longer than <paramref name="maxExperimentTimeInSeconds"/>.
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
/// model train to completion. For instance, if the first model
/// model train to completion. For instance, if the first model
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).</para>
/// </remarks>
public BinaryClassificationExperiment CreateBinaryClassificationExperiment(uint maxExperimentTimeInSeconds)
Expand Down Expand Up @@ -97,9 +97,9 @@ public BinaryClassificationExperiment CreateBinaryClassificationExperiment(Binar
/// <para>See <see cref="MulticlassClassificationExperiment"/> for a more detailed code example of an AutoML multiclass classification experiment.</para>
/// <para>An experiment may run for longer than <paramref name="maxExperimentTimeInSeconds"/>.
/// This is because once AutoML starts training an ML.NET model, AutoML lets the
/// model train to completion. For instance, if the first model
/// model train to completion. For instance, if the first model
/// AutoML trains takes 4 hours, and the second model trained takes 5 hours,
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// but <paramref name="maxExperimentTimeInSeconds"/> was the number of seconds in 6 hours,
/// the experiment will run for 4 + 5 = 9 hours (not 6 hours).</para>
/// </remarks>
public MulticlassClassificationExperiment CreateMulticlassClassificationExperiment(uint maxExperimentTimeInSeconds)
Expand Down Expand Up @@ -136,15 +136,15 @@ public MulticlassClassificationExperiment CreateMulticlassClassificationExperime
/// <returns>Information inferred about the columns in the provided dataset.</returns>
/// <remarks>
/// Infers information about the name, data type, and purpose of each column.
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
/// or used elsewhere in the ML.NET ecosystem (ie in <see cref="IEstimator{TTransformer}.Fit(IDataView)"/>.
/// The <see cref="ColumnInformation"/> contains the inferred purpose of each column in the dataset.
/// (For instance, is the column categorical, numeric, or text data? Should the column be ignored? Etc.)
/// The <see cref="ColumnInformation"/> can be inspected and modified (or kept as is) and used by an AutoML experiment.
/// </remarks>
public ColumnInferenceResults InferColumns(string path, string labelColumnName = DefaultColumnNames.Label, char? separatorChar = null, bool? allowQuoting = null,
public ColumnInferenceResults InferColumns(string path, string labelColumnName = DefaultColumnNames.Label, char? separatorChar = null, bool? allowQuoting = null,
bool? allowSparse = null, bool trimWhitespace = false, bool groupColumns = true)
{
UserInputValidationUtil.ValidateInferColumnsArgs(path, labelColumnName);
Expand All @@ -164,9 +164,9 @@ public ColumnInferenceResults InferColumns(string path, string labelColumnName =
/// <returns>Information inferred about the columns in the provided dataset.</returns>
/// <remarks>
/// Infers information about the name, data type, and purpose of each column.
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
/// or used elsewhere in the ML.NET ecosystem (ie in <see cref="IEstimator{TTransformer}.Fit(IDataView)"/>.
/// The <see cref="ColumnInformation"/> contains the inferred purpose of each column in the dataset.
/// (For instance, is the column categorical, numeric, or text data? Should the column be ignored? Etc.)
Expand Down Expand Up @@ -194,15 +194,15 @@ public ColumnInferenceResults InferColumns(string path, ColumnInformation column
/// <returns>Information inferred about the columns in the provided dataset.</returns>
/// <remarks>
/// Infers information about the name, data type, and purpose of each column.
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
/// The returned <see cref="ColumnInferenceResults.TextLoaderOptions" /> can be used to
/// instantiate a <see cref="TextLoader" />. The <see cref="TextLoader" /> can be used to
/// obtain an <see cref="IDataView"/> that can be fed into an AutoML experiment,
/// or used elsewhere in the ML.NET ecosystem (ie in <see cref="IEstimator{TTransformer}.Fit(IDataView)"/>.
/// The <see cref="ColumnInformation"/> contains the inferred purpose of each column in the dataset.
/// (For instance, is the column categorical, numeric, or text data? Should the column be ignored? Etc.)
/// The <see cref="ColumnInformation"/> can be inspected and modified (or kept as is) and used by an AutoML experiment.
/// </remarks>
public ColumnInferenceResults InferColumns(string path, uint labelColumnIndex, bool hasHeader = false, char? separatorChar = null,
public ColumnInferenceResults InferColumns(string path, uint labelColumnIndex, bool hasHeader = false, char? separatorChar = null,
bool? allowQuoting = null, bool? allowSparse = null, bool trimWhitespace = false, bool groupColumns = true)
{
UserInputValidationUtil.ValidateInferColumnsArgs(path);
Expand Down
21 changes: 14 additions & 7 deletions src/Microsoft.ML.AutoML/API/BinaryClassificationExperiment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@
namespace Microsoft.ML.AutoML
{
/// <summary>
/// Settings for AutoML experiments on binary classification datasets.
/// Settings for AutoML experiments on binary classification datasets.
/// </summary>
public sealed class BinaryExperimentSettings : ExperimentSettings
{
/// <summary>
/// Metric that AutoML will try to optimize over the course of the experiment.
/// </summary>
public BinaryClassificationMetric OptimizingMetric { get; set; } = BinaryClassificationMetric.Accuracy;
/// <value>The default value is <see cref="BinaryClassificationMetric.Accuracy"/>.</value>
public BinaryClassificationMetric OptimizingMetric { get; set; }

/// <summary>
/// Collection of trainers the AutoML experiment can leverage.
/// </summary>
/// <remarks>
/// The collection is auto-populated with all possible trainers (all values of <see cref="BinaryClassificationTrainer" />).
/// </remarks>
public ICollection<BinaryClassificationTrainer> Trainers { get; } =
Enum.GetValues(typeof(BinaryClassificationTrainer)).OfType<BinaryClassificationTrainer>().ToList();
/// <value>The default value is a collection auto-populated with all possible trainers (all values of <see cref="BinaryClassificationTrainer" />).</value>
public ICollection<BinaryClassificationTrainer> Trainers { get; }

/// <summary>
/// Initializes a new instance of <see cref="BinaryExperimentSettings"/>.
/// </summary>
public BinaryExperimentSettings()
{
OptimizingMetric = BinaryClassificationMetric.Accuracy;
Trainers = Enum.GetValues(typeof(BinaryClassificationTrainer)).OfType<BinaryClassificationTrainer>().ToList();
}
}

/// <summary>
Expand Down
36 changes: 25 additions & 11 deletions src/Microsoft.ML.AutoML/API/ColumnInference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ public sealed class ColumnInferenceResults
/// Can be used to instantiate a new <see cref="TextLoader" /> to load
/// data into an <see cref="IDataView" />.
/// </remarks>
public TextLoader.Options TextLoaderOptions { get; internal set; } = new TextLoader.Options();
public TextLoader.Options TextLoaderOptions { get; internal set; }

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

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

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

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

/// <summary>
/// The dataset columns that are numeric.
/// </summary>
public ICollection<string> NumericColumnNames { get; } = new Collection<string>();
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
public ICollection<string> NumericColumnNames { get; }

/// <summary>
/// The dataset columns that are text.
/// </summary>
public ICollection<string> TextColumnNames { get; } = new Collection<string>();
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
public ICollection<string> TextColumnNames { get; }

/// <summary>
/// The dataset columns that AutoML should ignore.
/// </summary>
public ICollection<string> IgnoredColumnNames { get; } = new Collection<string>();
/// <value>The default value is a new, empty <see cref="Collection{String}"/>.</value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 This should really be Collection{T}. See dotnet/csharplang#401.

public ICollection<string> IgnoredColumnNames { get; }

public ColumnInformation()
{
LabelColumnName = DefaultColumnNames.Label;
CategoricalColumnNames = new Collection<string>();
NumericColumnNames = new Collection<string>();
TextColumnNames = new Collection<string>();
IgnoredColumnNames = new Collection<string>();
}
}
}
Loading