From 726d486bdb280d43a2fd12c9e6da4021b190b773 Mon Sep 17 00:00:00 2001 From: Artidoro Pagnoni Date: Wed, 13 Mar 2019 15:50:31 -0700 Subject: [PATCH] One name for MulticlassClassification (#2919) --- .../LightGBMMulticlassWithInMemoryData.cs | 2 +- src/Microsoft.ML.Core/Data/AnnotationUtils.cs | 2 +- .../Prediction/IPredictor.cs | 2 +- src/Microsoft.ML.Core/Prediction/ITrainer.cs | 2 +- .../DataLoadSave/TransformerChain.cs | 2 +- .../EntryPoints/InputBuilder.cs | 6 +- .../Evaluators/EvaluatorUtils.cs | 2 +- ....cs => MulticlassClassificationMetrics.cs} | 20 ++-- ...s => MulticlassClassificationEvaluator.cs} | 100 +++++++++--------- .../Scorers/BinaryClassifierScorer.cs | 8 +- ...r.cs => MulticlassClassificationScorer.cs} | 32 +++--- .../Scorers/PredictionTransformer.cs | 4 +- .../Scorers/SchemaBindablePredictorWrapper.cs | 4 +- src/Microsoft.ML.Data/TrainCatalog.cs | 12 +-- .../Training/TrainerUtils.cs | 14 +-- .../EntryPoints/CreateEnsemble.cs | 4 +- .../EntryPoints/Ensemble.cs | 2 +- .../EntryPoints/OutputCombiner.cs | 2 +- .../EntryPoints/SubModelSelector.cs | 12 +-- .../OutputCombiners/BaseMultiCombiner.cs | 2 +- .../OutputCombiners/IOutputCombiner.cs | 4 +- .../OutputCombiners/MultiAverage.cs | 2 +- .../OutputCombiners/MultiMedian.cs | 2 +- .../OutputCombiners/MultiStacking.cs | 6 +- .../OutputCombiners/MultiWeightedAverage.cs | 6 +- src/Microsoft.ML.Ensemble/PipelineEnsemble.cs | 14 +-- ...MultiClass.cs => AllSelectorMulticlass.cs} | 10 +- .../SubModelSelector/BaseSubModelSelector.cs | 10 +- ...ss.cs => BestDiverseSelectorMulticlass.cs} | 12 +-- ...s => BestPerformanceSelectorMulticlass.cs} | 22 ++-- ...s => EnsembleMulticlassModelParameters.cs} | 20 ++-- .../MulticlassDataPartitionEnsembleTrainer.cs | 20 ++-- .../CrossValidationMacro.cs | 6 +- src/Microsoft.ML.EntryPoints/MacroUtils.cs | 6 +- .../OneVersusAllMacro.cs | 2 +- .../LightGbmStaticExtensions.cs | 4 +- .../LightGbmMulticlassTrainer.cs | 8 +- .../LightGbmTrainerBase.cs | 2 +- src/Microsoft.ML.SamplesUtils/ConsoleUtils.cs | 6 +- .../MulticlassLogisticRegression.cs | 10 +- .../MetaMulticlassTrainer.cs | 4 +- .../MulticlassNaiveBayesTrainer.cs} | 38 +++---- .../OneVersusAllTrainer.cs | 6 +- .../PairwiseCouplingTrainer.cs | 6 +- .../doc.xml | 4 +- .../{SdcaMultiClass.cs => SdcaMulticlass.cs} | 8 +- .../EvaluatorStaticExtensions.cs | 8 +- src/Microsoft.ML.StaticPipe/LbfgsStatic.cs | 8 +- ...tatic.cs => MulticlassNaiveBayesStatic.cs} | 12 +-- .../SdcaStaticExtensions.cs | 4 +- .../TrainerEstimatorReconciler.cs | 10 +- .../TrainingStaticExtensions.cs | 2 +- .../MetricStatistics.cs | 22 ++-- .../PermutationFeatureImportanceExtensions.cs | 14 +-- .../Common/EntryPoints/core_ep-list.tsv | 14 +-- .../Common/EntryPoints/core_manifest.json | 8 +- ...sticDualCoordinateAscentClassifierBench.cs | 6 +- .../Text/MultiClassClassification.cs | 8 +- .../UnitTests/TestEntryPoints.cs | 26 ++--- test/Microsoft.ML.Functional.Tests/Common.cs | 4 +- .../TestData/MultiClassifier/0.out.txt | 2 +- .../TestData/MultiClassifier/1.out.txt | 2 +- .../TestData/MultiClassifier/10.out.txt | 2 +- .../TestData/MultiClassifier/11.out.txt | 2 +- .../TestData/MultiClassifier/12.out.txt | 2 +- .../TestData/MultiClassifier/13.out.txt | 2 +- .../TestData/MultiClassifier/14.out.txt | 2 +- .../TestData/MultiClassifier/15.out.txt | 2 +- .../TestData/MultiClassifier/16.out.txt | 2 +- .../TestData/MultiClassifier/17.out.txt | 2 +- .../TestData/MultiClassifier/18.out.txt | 2 +- .../TestData/MultiClassifier/19.out.txt | 2 +- .../TestData/MultiClassifier/2.out.txt | 2 +- .../TestData/MultiClassifier/20.out.txt | 2 +- .../TestData/MultiClassifier/3.out.txt | 2 +- .../TestData/MultiClassifier/4.out.txt | 2 +- .../TestData/MultiClassifier/5.out.txt | 2 +- .../TestData/MultiClassifier/6.out.txt | 2 +- .../TestData/MultiClassifier/7.out.txt | 2 +- .../TestData/MultiClassifier/8.out.txt | 2 +- .../TestData/MultiClassifier/9.out.txt | 2 +- .../ResultProcessor/TestResultProcessor.cs | 4 +- .../TestPredictors.cs | 44 ++++---- .../Training.cs | 12 +-- test/Microsoft.ML.TestFramework/Learners.cs | 36 +++---- .../TestCommandBase.cs | 14 +-- .../IrisPlantClassificationTests.cs | 2 +- .../TrainerEstimators/LbfgsTests.cs | 2 +- .../TrainerEstimators/MetalinearEstimators.cs | 6 +- .../TrainerEstimators/TrainerEstimators.cs | 8 +- .../TrainerEstimators/TreeEstimators.cs | 10 +- 91 files changed, 399 insertions(+), 399 deletions(-) rename src/Microsoft.ML.Data/Evaluators/Metrics/{MultiClassClassifierMetrics.cs => MulticlassClassificationMetrics.cs} (82%) rename src/Microsoft.ML.Data/Evaluators/{MultiClassClassifierEvaluator.cs => MulticlassClassificationEvaluator.cs} (91%) rename src/Microsoft.ML.Data/Scorers/{MultiClassClassifierScorer.cs => MulticlassClassificationScorer.cs} (94%) rename src/Microsoft.ML.Ensemble/Selector/SubModelSelector/{AllSelectorMultiClass.cs => AllSelectorMulticlass.cs} (73%) rename src/Microsoft.ML.Ensemble/Selector/SubModelSelector/{BestDiverseSelectorMultiClass.cs => BestDiverseSelectorMulticlass.cs} (84%) rename src/Microsoft.ML.Ensemble/Selector/SubModelSelector/{BestPerformanceSelectorMultiClass.cs => BestPerformanceSelectorMulticlass.cs} (64%) rename src/Microsoft.ML.Ensemble/Trainer/Multiclass/{EnsembleMultiClassModelParameters.cs => EnsembleMulticlassModelParameters.cs} (91%) rename src/Microsoft.ML.StandardTrainers/Standard/{MultiClass => MulticlassClassification}/MetaMulticlassTrainer.cs (99%) rename src/Microsoft.ML.StandardTrainers/Standard/{MultiClass/MultiClassNaiveBayesTrainer.cs => MulticlassClassification/MulticlassNaiveBayesTrainer.cs} (93%) rename src/Microsoft.ML.StandardTrainers/Standard/{MultiClass => MulticlassClassification}/OneVersusAllTrainer.cs (99%) rename src/Microsoft.ML.StandardTrainers/Standard/{MultiClass => MulticlassClassification}/PairwiseCouplingTrainer.cs (99%) rename src/Microsoft.ML.StandardTrainers/Standard/{MultiClass => MulticlassClassification}/doc.xml (96%) rename src/Microsoft.ML.StandardTrainers/Standard/{SdcaMultiClass.cs => SdcaMulticlass.cs} (99%) rename src/Microsoft.ML.StaticPipe/{MultiClassNaiveBayesStatic.cs => MulticlassNaiveBayesStatic.cs} (87%) diff --git a/docs/samples/Microsoft.ML.Samples/Static/LightGBMMulticlassWithInMemoryData.cs b/docs/samples/Microsoft.ML.Samples/Static/LightGBMMulticlassWithInMemoryData.cs index c1974f350d..48191ab5e7 100644 --- a/docs/samples/Microsoft.ML.Samples/Static/LightGBMMulticlassWithInMemoryData.cs +++ b/docs/samples/Microsoft.ML.Samples/Static/LightGBMMulticlassWithInMemoryData.cs @@ -9,7 +9,7 @@ namespace Microsoft.ML.Samples.Static { class LightGBMMulticlassWithInMemoryData { - public void MultiClassLightGbmStaticPipelineWithInMemoryData() + public void MulticlassLightGbmStaticPipelineWithInMemoryData() { // Create a general context for ML.NET operations. It can be used for exception tracking and logging, // as a catalog of available operations and as the source of randomness. diff --git a/src/Microsoft.ML.Core/Data/AnnotationUtils.cs b/src/Microsoft.ML.Core/Data/AnnotationUtils.cs index 0fff1250bb..f8b827a739 100644 --- a/src/Microsoft.ML.Core/Data/AnnotationUtils.cs +++ b/src/Microsoft.ML.Core/Data/AnnotationUtils.cs @@ -87,7 +87,7 @@ public static class Const public static class ScoreColumnKind { public const string BinaryClassification = "BinaryClassification"; - public const string MultiClassClassification = "MultiClassClassification"; + public const string MulticlassClassification = "MulticlassClassification"; public const string Regression = "Regression"; public const string Ranking = "Ranking"; public const string Clustering = "Clustering"; diff --git a/src/Microsoft.ML.Core/Prediction/IPredictor.cs b/src/Microsoft.ML.Core/Prediction/IPredictor.cs index 171a77aba5..118375f134 100644 --- a/src/Microsoft.ML.Core/Prediction/IPredictor.cs +++ b/src/Microsoft.ML.Core/Prediction/IPredictor.cs @@ -19,7 +19,7 @@ internal enum PredictionKind Custom = 1, BinaryClassification = 2, - MultiClassClassification = 3, + MulticlassClassification = 3, Regression = 4, MultiOutputRegression = 5, Ranking = 6, diff --git a/src/Microsoft.ML.Core/Prediction/ITrainer.cs b/src/Microsoft.ML.Core/Prediction/ITrainer.cs index ad5a0b2539..92ab5bf885 100644 --- a/src/Microsoft.ML.Core/Prediction/ITrainer.cs +++ b/src/Microsoft.ML.Core/Prediction/ITrainer.cs @@ -19,7 +19,7 @@ namespace Microsoft.ML [BestFriend] internal delegate void SignatureBinaryClassifierTrainer(); [BestFriend] - internal delegate void SignatureMultiClassClassifierTrainer(); + internal delegate void SignatureMulticlassClassifierTrainer(); [BestFriend] internal delegate void SignatureRegressorTrainer(); [BestFriend] diff --git a/src/Microsoft.ML.Data/DataLoadSave/TransformerChain.cs b/src/Microsoft.ML.Data/DataLoadSave/TransformerChain.cs index a0d9577bfd..a20bc5113c 100644 --- a/src/Microsoft.ML.Data/DataLoadSave/TransformerChain.cs +++ b/src/Microsoft.ML.Data/DataLoadSave/TransformerChain.cs @@ -277,7 +277,7 @@ public static TransformerChain LoadFrom(IHostEnvironment env, Stre if (predictor.PredictionKind == PredictionKind.BinaryClassification) pred = new BinaryPredictionTransformer>(env, predictor as IPredictorProducing, chain.Schema, roles.Where(x => x.Key.Value == RoleMappedSchema.ColumnRole.Feature.Value).First().Value); - else if (predictor.PredictionKind == PredictionKind.MultiClassClassification) + else if (predictor.PredictionKind == PredictionKind.MulticlassClassification) pred = new MulticlassPredictionTransformer>>(env, predictor as IPredictorProducing>, chain.Schema, roles.Where(x => x.Key.Value == RoleMappedSchema.ColumnRole.Feature.Value).First().Value, diff --git a/src/Microsoft.ML.Data/EntryPoints/InputBuilder.cs b/src/Microsoft.ML.Data/EntryPoints/InputBuilder.cs index a33d59bced..1a32b903b8 100644 --- a/src/Microsoft.ML.Data/EntryPoints/InputBuilder.cs +++ b/src/Microsoft.ML.Data/EntryPoints/InputBuilder.cs @@ -839,11 +839,11 @@ public static class PipelineSweeperSupportedMetrics { public static new string ToString() => "SupportedMetric"; public const string Auc = BinaryClassifierEvaluator.Auc; - public const string AccuracyMicro = Data.MultiClassClassifierEvaluator.AccuracyMicro; - public const string AccuracyMacro = MultiClassClassifierEvaluator.AccuracyMacro; + public const string AccuracyMicro = Data.MulticlassClassificationEvaluator.AccuracyMicro; + public const string AccuracyMacro = MulticlassClassificationEvaluator.AccuracyMacro; public const string F1 = BinaryClassifierEvaluator.F1; public const string AuPrc = BinaryClassifierEvaluator.AuPrc; - public const string TopKAccuracy = MultiClassClassifierEvaluator.TopKAccuracy; + public const string TopKAccuracy = MulticlassClassificationEvaluator.TopKAccuracy; public const string L1 = RegressionLossEvaluatorBase.L1; public const string L2 = RegressionLossEvaluatorBase.L2; public const string Rms = RegressionLossEvaluatorBase.Rms; diff --git a/src/Microsoft.ML.Data/Evaluators/EvaluatorUtils.cs b/src/Microsoft.ML.Data/Evaluators/EvaluatorUtils.cs index e7d2f1668a..1fa68a9ff6 100644 --- a/src/Microsoft.ML.Data/Evaluators/EvaluatorUtils.cs +++ b/src/Microsoft.ML.Data/Evaluators/EvaluatorUtils.cs @@ -40,7 +40,7 @@ public static Dictionary> Instanc var tmp = new Dictionary> { { AnnotationUtils.Const.ScoreColumnKind.BinaryClassification, env => new BinaryClassifierMamlEvaluator(env, new BinaryClassifierMamlEvaluator.Arguments()) }, - { AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification, env => new MultiClassMamlEvaluator(env, new MultiClassMamlEvaluator.Arguments()) }, + { AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification, env => new MulticlassClassificationMamlEvaluator(env, new MulticlassClassificationMamlEvaluator.Arguments()) }, { AnnotationUtils.Const.ScoreColumnKind.Regression, env => new RegressionMamlEvaluator(env, new RegressionMamlEvaluator.Arguments()) }, { AnnotationUtils.Const.ScoreColumnKind.MultiOutputRegression, env => new MultiOutputRegressionMamlEvaluator(env, new MultiOutputRegressionMamlEvaluator.Arguments()) }, { AnnotationUtils.Const.ScoreColumnKind.QuantileRegression, env => new QuantileRegressionMamlEvaluator(env, new QuantileRegressionMamlEvaluator.Arguments()) }, diff --git a/src/Microsoft.ML.Data/Evaluators/Metrics/MultiClassClassifierMetrics.cs b/src/Microsoft.ML.Data/Evaluators/Metrics/MulticlassClassificationMetrics.cs similarity index 82% rename from src/Microsoft.ML.Data/Evaluators/Metrics/MultiClassClassifierMetrics.cs rename to src/Microsoft.ML.Data/Evaluators/Metrics/MulticlassClassificationMetrics.cs index f9f189eb70..e0d45233a5 100644 --- a/src/Microsoft.ML.Data/Evaluators/Metrics/MultiClassClassifierMetrics.cs +++ b/src/Microsoft.ML.Data/Evaluators/Metrics/MulticlassClassificationMetrics.cs @@ -10,9 +10,9 @@ namespace Microsoft.ML.Data { /// - /// Evaluation results for multi-class classifiers. + /// Evaluation results for multi-class classification trainers. /// - public sealed class MultiClassClassifierMetrics + public sealed class MulticlassClassificationMetrics { /// /// Gets the average log-loss of the classifier. @@ -83,22 +83,22 @@ public sealed class MultiClassClassifierMetrics /// public IReadOnlyList PerClassLogLoss { get; } - internal MultiClassClassifierMetrics(IExceptionContext ectx, DataViewRow overallResult, int topK) + internal MulticlassClassificationMetrics(IExceptionContext ectx, DataViewRow overallResult, int topK) { double FetchDouble(string name) => RowCursorUtils.Fetch(ectx, overallResult, name); - MicroAccuracy = FetchDouble(MultiClassClassifierEvaluator.AccuracyMicro); - MacroAccuracy = FetchDouble(MultiClassClassifierEvaluator.AccuracyMacro); - LogLoss = FetchDouble(MultiClassClassifierEvaluator.LogLoss); - LogLossReduction = FetchDouble(MultiClassClassifierEvaluator.LogLossReduction); + MicroAccuracy = FetchDouble(MulticlassClassificationEvaluator.AccuracyMicro); + MacroAccuracy = FetchDouble(MulticlassClassificationEvaluator.AccuracyMacro); + LogLoss = FetchDouble(MulticlassClassificationEvaluator.LogLoss); + LogLossReduction = FetchDouble(MulticlassClassificationEvaluator.LogLossReduction); TopK = topK; if (topK > 0) - TopKAccuracy = FetchDouble(MultiClassClassifierEvaluator.TopKAccuracy); + TopKAccuracy = FetchDouble(MulticlassClassificationEvaluator.TopKAccuracy); - var perClassLogLoss = RowCursorUtils.Fetch>(ectx, overallResult, MultiClassClassifierEvaluator.PerClassLogLoss); + var perClassLogLoss = RowCursorUtils.Fetch>(ectx, overallResult, MulticlassClassificationEvaluator.PerClassLogLoss); PerClassLogLoss = perClassLogLoss.DenseValues().ToImmutableArray(); } - internal MultiClassClassifierMetrics(double accuracyMicro, double accuracyMacro, double logLoss, double logLossReduction, + internal MulticlassClassificationMetrics(double accuracyMicro, double accuracyMacro, double logLoss, double logLossReduction, int topK, double topKAccuracy, double[] perClassLogLoss) { MicroAccuracy = accuracyMicro; diff --git a/src/Microsoft.ML.Data/Evaluators/MultiClassClassifierEvaluator.cs b/src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs similarity index 91% rename from src/Microsoft.ML.Data/Evaluators/MultiClassClassifierEvaluator.cs rename to src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs index 651ab1439b..9095623368 100644 --- a/src/Microsoft.ML.Data/Evaluators/MultiClassClassifierEvaluator.cs +++ b/src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs @@ -15,20 +15,20 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Transforms; -[assembly: LoadableClass(typeof(MultiClassClassifierEvaluator), typeof(MultiClassClassifierEvaluator), typeof(MultiClassClassifierEvaluator.Arguments), typeof(SignatureEvaluator), - "Multi-Class Classifier Evaluator", MultiClassClassifierEvaluator.LoadName, "MultiClassClassifier", "MultiClass")] +[assembly: LoadableClass(typeof(MulticlassClassificationEvaluator), typeof(MulticlassClassificationEvaluator), typeof(MulticlassClassificationEvaluator.Arguments), typeof(SignatureEvaluator), + "Multi-Class Classifier Evaluator", MulticlassClassificationEvaluator.LoadName, "MultiClassClassifier", "MultiClass")] -[assembly: LoadableClass(typeof(MultiClassMamlEvaluator), typeof(MultiClassMamlEvaluator), typeof(MultiClassMamlEvaluator.Arguments), typeof(SignatureMamlEvaluator), - "Multi-Class Classifier Evaluator", MultiClassClassifierEvaluator.LoadName, "MultiClassClassifier", "MultiClass")] +[assembly: LoadableClass(typeof(MulticlassClassificationMamlEvaluator), typeof(MulticlassClassificationMamlEvaluator), typeof(MulticlassClassificationMamlEvaluator.Arguments), typeof(SignatureMamlEvaluator), + "Multi-Class Classifier Evaluator", MulticlassClassificationEvaluator.LoadName, "MultiClassClassifier", "MultiClass")] // This is for deserialization of the per-instance transform. -[assembly: LoadableClass(typeof(MultiClassPerInstanceEvaluator), null, typeof(SignatureLoadRowMapper), - "", MultiClassPerInstanceEvaluator.LoaderSignature)] +[assembly: LoadableClass(typeof(MulticlassPerInstanceEvaluator), null, typeof(SignatureLoadRowMapper), + "", MulticlassPerInstanceEvaluator.LoaderSignature)] namespace Microsoft.ML.Data { [BestFriend] - internal sealed class MultiClassClassifierEvaluator : RowToRowEvaluatorBase + internal sealed class MulticlassClassificationEvaluator : RowToRowEvaluatorBase { public sealed class Arguments { @@ -48,13 +48,13 @@ public sealed class Arguments public enum Metrics { - [EnumValueDisplay(MultiClassClassifierEvaluator.AccuracyMicro)] + [EnumValueDisplay(MulticlassClassificationEvaluator.AccuracyMicro)] AccuracyMicro, - [EnumValueDisplay(MultiClassClassifierEvaluator.AccuracyMacro)] + [EnumValueDisplay(MulticlassClassificationEvaluator.AccuracyMacro)] AccuracyMacro, - [EnumValueDisplay(MultiClassClassifierEvaluator.LogLoss)] + [EnumValueDisplay(MulticlassClassificationEvaluator.LogLoss)] LogLoss, - [EnumValueDisplay(MultiClassClassifierEvaluator.LogLossReduction)] + [EnumValueDisplay(MulticlassClassificationEvaluator.LogLossReduction)] LogLossReduction, } @@ -63,7 +63,7 @@ public enum Metrics private readonly int? _outputTopKAcc; private readonly bool _names; - public MultiClassClassifierEvaluator(IHostEnvironment env, Arguments args) + public MulticlassClassificationEvaluator(IHostEnvironment env, Arguments args) : base(env, LoadName) { Host.AssertValue(args, "args"); @@ -122,7 +122,7 @@ private protected override IRowMapper CreatePerInstanceRowMapper(RoleMappedSchem Host.CheckParam(schema.Label.HasValue, nameof(schema), "Schema must contain a label column"); var scoreInfo = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score); int numClasses = scoreInfo.Type.GetVectorSize(); - return new MultiClassPerInstanceEvaluator(Host, schema.Schema, scoreInfo, schema.Label.Value.Name); + return new MulticlassPerInstanceEvaluator(Host, schema.Schema, scoreInfo, schema.Label.Value.Name); } public override IEnumerable GetOverallMetricColumns() @@ -504,7 +504,7 @@ public void GetSlotNames(ref VBuffer> slotNames) /// The name of the score column in . /// The name of the predicted label column in . /// The evaluation results for these outputs. - public MultiClassClassifierMetrics Evaluate(IDataView data, string label, string score, string predictedLabel) + public MulticlassClassificationMetrics Evaluate(IDataView data, string label, string score, string predictedLabel) { Host.CheckValue(data, nameof(data)); Host.CheckNonEmpty(label, nameof(label)); @@ -520,12 +520,12 @@ public MultiClassClassifierMetrics Evaluate(IDataView data, string label, string Host.Assert(resultDict.ContainsKey(MetricKinds.OverallMetrics)); var overall = resultDict[MetricKinds.OverallMetrics]; - MultiClassClassifierMetrics result; + MulticlassClassificationMetrics result; using (var cursor = overall.GetRowCursorForAllColumns()) { var moved = cursor.MoveNext(); Host.Assert(moved); - result = new MultiClassClassifierMetrics(Host, cursor, _outputTopKAcc ?? 0); + result = new MulticlassClassificationMetrics(Host, cursor, _outputTopKAcc ?? 0); moved = cursor.MoveNext(); Host.Assert(!moved); } @@ -534,7 +534,7 @@ public MultiClassClassifierMetrics Evaluate(IDataView data, string label, string } - internal sealed class MultiClassPerInstanceEvaluator : PerInstanceEvaluatorBase + internal sealed class MulticlassPerInstanceEvaluator : PerInstanceEvaluatorBase { public const string LoaderSignature = "MulticlassPerInstance"; private static VersionInfo GetVersionInfo() @@ -546,7 +546,7 @@ private static VersionInfo GetVersionInfo() verReadableCur: 0x00010002, verWeCanReadBack: 0x00010001, loaderSignature: LoaderSignature, - loaderAssemblyName: typeof(MultiClassPerInstanceEvaluator).Assembly.FullName); + loaderAssemblyName: typeof(MulticlassPerInstanceEvaluator).Assembly.FullName); } private const int AssignedCol = 0; @@ -567,7 +567,7 @@ private static VersionInfo GetVersionInfo() private readonly ReadOnlyMemory[] _classNames; private readonly DataViewType[] _types; - public MultiClassPerInstanceEvaluator(IHostEnvironment env, DataViewSchema schema, DataViewSchema.Column scoreColumn, string labelCol) + public MulticlassPerInstanceEvaluator(IHostEnvironment env, DataViewSchema schema, DataViewSchema.Column scoreColumn, string labelCol) : base(env, schema, scoreColumn.Name, labelCol) { CheckInputColumnTypes(schema); @@ -592,7 +592,7 @@ public MultiClassPerInstanceEvaluator(IHostEnvironment env, DataViewSchema schem _types[SortedClassesCol] = new VectorType(key, _numClasses); } - private MultiClassPerInstanceEvaluator(IHostEnvironment env, ModelLoadContext ctx, DataViewSchema schema) + private MulticlassPerInstanceEvaluator(IHostEnvironment env, ModelLoadContext ctx, DataViewSchema schema) : base(env, ctx, schema) { CheckInputColumnTypes(schema); @@ -621,13 +621,13 @@ private MultiClassPerInstanceEvaluator(IHostEnvironment env, ModelLoadContext ct _types[SortedClassesCol] = new VectorType(key, _numClasses); } - public static MultiClassPerInstanceEvaluator Create(IHostEnvironment env, ModelLoadContext ctx, DataViewSchema schema) + public static MulticlassPerInstanceEvaluator Create(IHostEnvironment env, ModelLoadContext ctx, DataViewSchema schema) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(ctx, nameof(ctx)); ctx.CheckAtModel(GetVersionInfo()); - return new MultiClassPerInstanceEvaluator(env, ctx, schema); + return new MulticlassPerInstanceEvaluator(env, ctx, schema); } private protected override void SaveModel(ModelSaveContext ctx) @@ -823,7 +823,7 @@ private void CheckInputColumnTypes(DataViewSchema schema) } [BestFriend] - internal sealed class MultiClassMamlEvaluator : MamlEvaluatorBase + internal sealed class MulticlassClassificationMamlEvaluator : MamlEvaluatorBase { public class Arguments : ArgumentsBase { @@ -846,12 +846,12 @@ public class Arguments : ArgumentsBase private readonly int _numTopClasses; private readonly int _numConfusionTableClasses; private readonly int? _outputTopKAcc; - private readonly MultiClassClassifierEvaluator _evaluator; + private readonly MulticlassClassificationEvaluator _evaluator; private protected override IEvaluator Evaluator => _evaluator; - public MultiClassMamlEvaluator(IHostEnvironment env, Arguments args) - : base(args, env, AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification, "MultiClassMamlEvaluator") + public MulticlassClassificationMamlEvaluator(IHostEnvironment env, Arguments args) + : base(args, env, AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification, "MultiClassMamlEvaluator") { Host.CheckValue(args, nameof(args)); // REVIEW: why do we need to insist on at least 2? @@ -865,11 +865,11 @@ public MultiClassMamlEvaluator(IHostEnvironment env, Arguments args) _numConfusionTableClasses = args.NumClassesConfusionMatrix; _outputTopKAcc = args.OutputTopKAcc; - var evalArgs = new MultiClassClassifierEvaluator.Arguments + var evalArgs = new MulticlassClassificationEvaluator.Arguments { OutputTopKAcc = _outputTopKAcc }; - _evaluator = new MultiClassClassifierEvaluator(Host, evalArgs); + _evaluator = new MulticlassClassificationEvaluator(Host, evalArgs); } private protected override void PrintFoldResultsCore(IChannel ch, Dictionary metrics) @@ -918,7 +918,7 @@ private protected override IDataView CombineOverallMetricsCore(IDataView[] metri if (_outputPerClass) { - EvaluateUtils.ReconcileSlotNames(Host, views, MultiClassClassifierEvaluator.PerClassLogLoss, NumberDataViewType.Double, + EvaluateUtils.ReconcileSlotNames(Host, views, MulticlassClassificationEvaluator.PerClassLogLoss, NumberDataViewType.Double, def: double.NaN); for (int i = 0; i < overallList.Count; i++) { @@ -928,7 +928,7 @@ private protected override IDataView CombineOverallMetricsCore(IDataView[] metri for (int col = 0; col < idv.Schema.Count; col++) { if (idv.Schema[col].IsHidden && - idv.Schema[col].Name.Equals(MultiClassClassifierEvaluator.PerClassLogLoss)) + idv.Schema[col].Name.Equals(MulticlassClassificationEvaluator.PerClassLogLoss)) { idv = new ChooseColumnsByIndexTransform(Host, new ChooseColumnsByIndexTransform.Options() { Drop = true, Indices = new[] { col } }, idv); @@ -951,32 +951,32 @@ private protected override IDataView GetOverallResultsCore(IDataView overall) private IDataView ChangeTopKAccColumnName(IDataView input) { - input = new ColumnCopyingTransformer(Host, (string.Format(TopKAccuracyFormat, _outputTopKAcc), MultiClassClassifierEvaluator.TopKAccuracy)).Transform(input); - return ColumnSelectingTransformer.CreateDrop(Host, input, MultiClassClassifierEvaluator.TopKAccuracy); + input = new ColumnCopyingTransformer(Host, (string.Format(TopKAccuracyFormat, _outputTopKAcc), MulticlassClassificationEvaluator.TopKAccuracy)).Transform(input); + return ColumnSelectingTransformer.CreateDrop(Host, input, MulticlassClassificationEvaluator.TopKAccuracy); } private IDataView DropPerClassColumn(IDataView input) { - if (input.Schema.TryGetColumnIndex(MultiClassClassifierEvaluator.PerClassLogLoss, out int perClassCol)) + if (input.Schema.TryGetColumnIndex(MulticlassClassificationEvaluator.PerClassLogLoss, out int perClassCol)) { - input = ColumnSelectingTransformer.CreateDrop(Host, input, MultiClassClassifierEvaluator.PerClassLogLoss); + input = ColumnSelectingTransformer.CreateDrop(Host, input, MulticlassClassificationEvaluator.PerClassLogLoss); } return input; } public override IEnumerable GetOverallMetricColumns() { - yield return new MetricColumn("AccuracyMicro", MultiClassClassifierEvaluator.AccuracyMicro); - yield return new MetricColumn("AccuracyMacro", MultiClassClassifierEvaluator.AccuracyMacro); + yield return new MetricColumn("AccuracyMicro", MulticlassClassificationEvaluator.AccuracyMicro); + yield return new MetricColumn("AccuracyMacro", MulticlassClassificationEvaluator.AccuracyMacro); yield return new MetricColumn("TopKAccuracy", string.Format(TopKAccuracyFormat, _outputTopKAcc)); if (_outputPerClass) { yield return new MetricColumn("LogLoss", - MultiClassClassifierEvaluator.PerClassLogLoss, MetricColumn.Objective.Minimize, isVector: true, - namePattern: new Regex(string.Format(@"^{0}(?.+)", MultiClassClassifierEvaluator.LogLoss), RegexOptions.IgnoreCase)); + MulticlassClassificationEvaluator.PerClassLogLoss, MetricColumn.Objective.Minimize, isVector: true, + namePattern: new Regex(string.Format(@"^{0}(?.+)", MulticlassClassificationEvaluator.LogLoss), RegexOptions.IgnoreCase)); } - yield return new MetricColumn("LogLoss", MultiClassClassifierEvaluator.LogLoss, MetricColumn.Objective.Minimize); - yield return new MetricColumn("LogLossReduction", MultiClassClassifierEvaluator.LogLossReduction); + yield return new MetricColumn("LogLoss", MulticlassClassificationEvaluator.LogLoss, MetricColumn.Objective.Minimize); + yield return new MetricColumn("LogLossReduction", MulticlassClassificationEvaluator.LogLossReduction); } private protected override IEnumerable GetPerInstanceColumnsToSave(RoleMappedSchema schema) @@ -988,10 +988,10 @@ private protected override IEnumerable GetPerInstanceColumnsToSave(RoleM yield return schema.Label.Value.Name; // Return the output columns. - yield return MultiClassPerInstanceEvaluator.Assigned; - yield return MultiClassPerInstanceEvaluator.LogLoss; - yield return MultiClassPerInstanceEvaluator.SortedScores; - yield return MultiClassPerInstanceEvaluator.SortedClasses; + yield return MulticlassPerInstanceEvaluator.Assigned; + yield return MulticlassPerInstanceEvaluator.LogLoss; + yield return MulticlassPerInstanceEvaluator.SortedScores; + yield return MulticlassPerInstanceEvaluator.SortedClasses; } // Multi-class evaluator adds four per-instance columns: "Assigned", "Top scores", "Top classes" and "Log-loss". @@ -1012,20 +1012,20 @@ private protected override IDataView GetPerInstanceMetricsCore(IDataView perInst } var perInstSchema = perInst.Schema; - if (perInstSchema.TryGetColumnIndex(MultiClassPerInstanceEvaluator.SortedClasses, out int sortedClassesIndex)) + if (perInstSchema.TryGetColumnIndex(MulticlassPerInstanceEvaluator.SortedClasses, out int sortedClassesIndex)) { var type = perInstSchema[sortedClassesIndex].Type; // Wrap with a DropSlots transform to pick only the first _numTopClasses slots. if (_numTopClasses < type.GetVectorSize()) - perInst = new SlotsDroppingTransformer(Host, MultiClassPerInstanceEvaluator.SortedClasses, min: _numTopClasses).Transform(perInst); + perInst = new SlotsDroppingTransformer(Host, MulticlassPerInstanceEvaluator.SortedClasses, min: _numTopClasses).Transform(perInst); } // Wrap with a DropSlots transform to pick only the first _numTopClasses slots. - if (perInst.Schema.TryGetColumnIndex(MultiClassPerInstanceEvaluator.SortedScores, out int sortedScoresIndex)) + if (perInst.Schema.TryGetColumnIndex(MulticlassPerInstanceEvaluator.SortedScores, out int sortedScoresIndex)) { var type = perInst.Schema[sortedScoresIndex].Type; if (_numTopClasses < type.GetVectorSize()) - perInst = new SlotsDroppingTransformer(Host, MultiClassPerInstanceEvaluator.SortedScores, min: _numTopClasses).Transform(perInst); + perInst = new SlotsDroppingTransformer(Host, MulticlassPerInstanceEvaluator.SortedScores, min: _numTopClasses).Transform(perInst); } return perInst; } @@ -1034,7 +1034,7 @@ private protected override IDataView GetPerInstanceMetricsCore(IDataView perInst internal static partial class Evaluate { [TlcModule.EntryPoint(Name = "Models.ClassificationEvaluator", Desc = "Evaluates a multi class classification scored dataset.")] - public static CommonOutputs.ClassificationEvaluateOutput MultiClass(IHostEnvironment env, MultiClassMamlEvaluator.Arguments input) + public static CommonOutputs.ClassificationEvaluateOutput Multiclass(IHostEnvironment env, MulticlassClassificationMamlEvaluator.Arguments input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("EvaluateMultiClass"); @@ -1042,7 +1042,7 @@ public static CommonOutputs.ClassificationEvaluateOutput MultiClass(IHostEnviron EntryPointUtils.CheckInputArgs(host, input); MatchColumns(host, input, out string label, out string weight, out string name); - IMamlEvaluator evaluator = new MultiClassMamlEvaluator(host, input); + IMamlEvaluator evaluator = new MulticlassClassificationMamlEvaluator(host, input); var data = new RoleMappedData(input.Data, label, null, null, weight, name); var metrics = evaluator.Evaluate(data); diff --git a/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs b/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs index 5f2f1d9d7d..271fda440e 100644 --- a/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs +++ b/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs @@ -73,7 +73,7 @@ private static ISchemaBoundMapper WrapIfNeeded(IHostEnvironment env, ISchemaBoun } /// - /// This is a utility method used to determine whether + /// This is a utility method used to determine whether /// can or should be used to wrap . This will not throw, since the /// desired behavior in the event that it cannot be wrapped, is to just back off to the original /// "unwrapped" bound mapper. @@ -82,7 +82,7 @@ private static ISchemaBoundMapper WrapIfNeeded(IHostEnvironment env, ISchemaBoun /// The type of the label names from the metadata (either /// originating from the key value metadata of the training label column, or deserialized /// from the model of a bindable mapper) - /// Whether we can call with + /// Whether we can call with /// this mapper and expect it to succeed private static bool CanWrap(ISchemaBoundMapper mapper, DataViewType labelNameType) { @@ -119,7 +119,7 @@ private static ISchemaBoundMapper WrapCore(IHostEnvironment env, ISchemaBound ValueGetter> getter = (ref VBuffer value) => labelColumn.GetKeyValues(ref value); - return MultiClassClassifierScorer.LabelNameBindableMapper.CreateBound(env, (ISchemaBoundRowMapper)mapper, type, getter, AnnotationUtils.Kinds.TrainingLabelValues, CanWrap); + return MulticlassClassificationScorer.LabelNameBindableMapper.CreateBound(env, (ISchemaBoundRowMapper)mapper, type, getter, AnnotationUtils.Kinds.TrainingLabelValues, CanWrap); } [BestFriend] @@ -288,7 +288,7 @@ private protected override JToken PredictedLabelPfa(string[] mapperOutputs) private static DataViewType GetPredColType(DataViewType scoreType, ISchemaBoundRowMapper mapper) { - var labelNameBindableMapper = mapper.Bindable as MultiClassClassifierScorer.LabelNameBindableMapper; + var labelNameBindableMapper = mapper.Bindable as MulticlassClassificationScorer.LabelNameBindableMapper; if (labelNameBindableMapper == null) return BooleanDataViewType.Instance; return new KeyType(typeof(uint), labelNameBindableMapper.Type.Size); diff --git a/src/Microsoft.ML.Data/Scorers/MultiClassClassifierScorer.cs b/src/Microsoft.ML.Data/Scorers/MulticlassClassificationScorer.cs similarity index 94% rename from src/Microsoft.ML.Data/Scorers/MultiClassClassifierScorer.cs rename to src/Microsoft.ML.Data/Scorers/MulticlassClassificationScorer.cs index fb2fd7dd34..73bb907b5a 100644 --- a/src/Microsoft.ML.Data/Scorers/MultiClassClassifierScorer.cs +++ b/src/Microsoft.ML.Data/Scorers/MulticlassClassificationScorer.cs @@ -16,20 +16,20 @@ using Microsoft.ML.Runtime; using Newtonsoft.Json.Linq; -[assembly: LoadableClass(typeof(MultiClassClassifierScorer), - typeof(MultiClassClassifierScorer.Arguments), typeof(SignatureDataScorer), +[assembly: LoadableClass(typeof(MulticlassClassificationScorer), + typeof(MulticlassClassificationScorer.Arguments), typeof(SignatureDataScorer), "Multi-Class Classifier Scorer", "MultiClassClassifierScorer", "MultiClassClassifier", - "MultiClass", AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification)] + "MultiClass", AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification)] -[assembly: LoadableClass(typeof(MultiClassClassifierScorer), null, typeof(SignatureLoadDataTransform), - "Multi-Class Classifier Scorer", MultiClassClassifierScorer.LoaderSignature)] +[assembly: LoadableClass(typeof(MulticlassClassificationScorer), null, typeof(SignatureLoadDataTransform), + "Multi-Class Classifier Scorer", MulticlassClassificationScorer.LoaderSignature)] -[assembly: LoadableClass(typeof(ISchemaBindableMapper), typeof(MultiClassClassifierScorer.LabelNameBindableMapper), null, typeof(SignatureLoadModel), - "Multi-Class Label-Name Mapper", MultiClassClassifierScorer.LabelNameBindableMapper.LoaderSignature)] +[assembly: LoadableClass(typeof(ISchemaBindableMapper), typeof(MulticlassClassificationScorer.LabelNameBindableMapper), null, typeof(SignatureLoadModel), + "Multi-Class Label-Name Mapper", MulticlassClassificationScorer.LabelNameBindableMapper.LoaderSignature)] namespace Microsoft.ML.Data { - internal sealed class MultiClassClassifierScorer : PredictedLabelScorerBase + internal sealed class MulticlassClassificationScorer : PredictedLabelScorerBase { // REVIEW: consider outputting probabilities when multi-class classifiers distinguish // between scores and probabilities (using IDistributionPredictor) @@ -48,7 +48,7 @@ private static VersionInfo GetVersionInfo() verReadableCur: 0x00010003, verWeCanReadBack: 0x00010003, loaderSignature: LoaderSignature, - loaderAssemblyName: typeof(MultiClassClassifierScorer).Assembly.FullName); + loaderAssemblyName: typeof(MulticlassClassificationScorer).Assembly.FullName); } private const string RegistrationName = "MultiClassClassifierScore"; @@ -455,18 +455,18 @@ internal static ISchemaBoundMapper WrapCore(IHostEnvironment env, ISchemaBoun } [BestFriend] - internal MultiClassClassifierScorer(IHostEnvironment env, Arguments args, IDataView data, ISchemaBoundMapper mapper, RoleMappedSchema trainSchema) - : base(args, env, data, WrapIfNeeded(env, mapper, trainSchema), trainSchema, RegistrationName, AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification, + internal MulticlassClassificationScorer(IHostEnvironment env, Arguments args, IDataView data, ISchemaBoundMapper mapper, RoleMappedSchema trainSchema) + : base(args, env, data, WrapIfNeeded(env, mapper, trainSchema), trainSchema, RegistrationName, AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification, AnnotationUtils.Const.ScoreValueKind.Score, OutputTypeMatches, GetPredColType) { } - private MultiClassClassifierScorer(IHostEnvironment env, MultiClassClassifierScorer transform, IDataView newSource) + private MulticlassClassificationScorer(IHostEnvironment env, MulticlassClassificationScorer transform, IDataView newSource) : base(env, transform, newSource, RegistrationName) { } - private MultiClassClassifierScorer(IHost host, ModelLoadContext ctx, IDataView input) + private MulticlassClassificationScorer(IHost host, ModelLoadContext ctx, IDataView input) : base(host, ctx, input, OutputTypeMatches, GetPredColType) { // *** Binary format *** @@ -476,14 +476,14 @@ private MultiClassClassifierScorer(IHost host, ModelLoadContext ctx, IDataView i /// /// Corresponds to . /// - private static MultiClassClassifierScorer Create(IHostEnvironment env, ModelLoadContext ctx, IDataView input) + private static MulticlassClassificationScorer Create(IHostEnvironment env, ModelLoadContext ctx, IDataView input) { Contracts.CheckValue(env, nameof(env)); var h = env.Register(RegistrationName); h.CheckValue(ctx, nameof(ctx)); h.CheckValue(input, nameof(input)); ctx.CheckAtModel(GetVersionInfo()); - return h.Apply("Loading Model", ch => new MultiClassClassifierScorer(h, ctx, input)); + return h.Apply("Loading Model", ch => new MulticlassClassificationScorer(h, ctx, input)); } private protected override void SaveCore(ModelSaveContext ctx) @@ -502,7 +502,7 @@ private protected override IDataTransform ApplyToDataCore(IHostEnvironment env, Contracts.CheckValue(env, nameof(env)); Contracts.CheckValue(newSource, nameof(newSource)); - return new MultiClassClassifierScorer(env, this, newSource); + return new MulticlassClassificationScorer(env, this, newSource); } protected override Delegate GetPredictedLabelGetter(DataViewRow output, out Delegate scoreGetter) diff --git a/src/Microsoft.ML.Data/Scorers/PredictionTransformer.cs b/src/Microsoft.ML.Data/Scorers/PredictionTransformer.cs index be6757bc36..0dd61bcbe4 100644 --- a/src/Microsoft.ML.Data/Scorers/PredictionTransformer.cs +++ b/src/Microsoft.ML.Data/Scorers/PredictionTransformer.cs @@ -427,8 +427,8 @@ internal MulticlassPredictionTransformer(IHostEnvironment env, ModelLoadContext private void SetScorer() { var schema = new RoleMappedSchema(TrainSchema, _trainLabelColumn, FeatureColumn); - var args = new MultiClassClassifierScorer.Arguments(); - Scorer = new MultiClassClassifierScorer(Host, args, new EmptyDataView(Host, TrainSchema), BindableMapper.Bind(Host, schema), schema); + var args = new MulticlassClassificationScorer.Arguments(); + Scorer = new MulticlassClassificationScorer(Host, args, new EmptyDataView(Host, TrainSchema), BindableMapper.Bind(Host, schema), schema); } private protected override void SaveCore(ModelSaveContext ctx) diff --git a/src/Microsoft.ML.Data/Scorers/SchemaBindablePredictorWrapper.cs b/src/Microsoft.ML.Data/Scorers/SchemaBindablePredictorWrapper.cs index d8507617a4..ee22a12f4a 100644 --- a/src/Microsoft.ML.Data/Scorers/SchemaBindablePredictorWrapper.cs +++ b/src/Microsoft.ML.Data/Scorers/SchemaBindablePredictorWrapper.cs @@ -335,8 +335,8 @@ private static string GetScoreColumnKind(IPredictor predictor) { case PredictionKind.BinaryClassification: return AnnotationUtils.Const.ScoreColumnKind.BinaryClassification; - case PredictionKind.MultiClassClassification: - return AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification; + case PredictionKind.MulticlassClassification: + return AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification; case PredictionKind.Regression: return AnnotationUtils.Const.ScoreColumnKind.Regression; case PredictionKind.MultiOutputRegression: diff --git a/src/Microsoft.ML.Data/TrainCatalog.cs b/src/Microsoft.ML.Data/TrainCatalog.cs index 6e8103f828..445c190740 100644 --- a/src/Microsoft.ML.Data/TrainCatalog.cs +++ b/src/Microsoft.ML.Data/TrainCatalog.cs @@ -485,11 +485,11 @@ internal MulticlassClassificationTrainers(MulticlassClassificationCatalog catalo /// The name of the label column in . /// The name of the score column in . /// The name of the predicted label column in . - /// If given a positive value, the will be filled with + /// If given a positive value, the will be filled with /// the top-K accuracy, that is, the accuracy assuming we consider an example with the correct class within /// the top-K values as being stored "correctly." /// The evaluation results for these calibrated outputs. - public MultiClassClassifierMetrics Evaluate(IDataView data, string label = DefaultColumnNames.Label, string score = DefaultColumnNames.Score, + public MulticlassClassificationMetrics Evaluate(IDataView data, string label = DefaultColumnNames.Label, string score = DefaultColumnNames.Score, string predictedLabel = DefaultColumnNames.PredictedLabel, int topK = 0) { Environment.CheckValue(data, nameof(data)); @@ -497,10 +497,10 @@ public MultiClassClassifierMetrics Evaluate(IDataView data, string label = Defau Environment.CheckNonEmpty(score, nameof(score)); Environment.CheckNonEmpty(predictedLabel, nameof(predictedLabel)); - var args = new MultiClassClassifierEvaluator.Arguments() { }; + var args = new MulticlassClassificationEvaluator.Arguments() { }; if (topK > 0) args.OutputTopKAcc = topK; - var eval = new MultiClassClassifierEvaluator(Environment, args); + var eval = new MulticlassClassificationEvaluator(Environment, args); return eval.Evaluate(data, label, score, predictedLabel); } @@ -519,13 +519,13 @@ public MultiClassClassifierMetrics Evaluate(IDataView data, string label = Defau /// Seed for the random number generator used to select rows for cross-validation folds. /// Per-fold results: metrics, models, scored datasets. /// Per-fold results: metrics, models, scored datasets. - public CrossValidationResult[] CrossValidate( + public CrossValidationResult[] CrossValidate( IDataView data, IEstimator estimator, int numFolds = 5, string labelColumn = DefaultColumnNames.Label, string samplingKeyColumn = null, int? seed = null) { Environment.CheckNonEmpty(labelColumn, nameof(labelColumn)); var result = CrossValidateTrain(data, estimator, numFolds, samplingKeyColumn, seed); - return result.Select(x => new CrossValidationResult(x.Model, + return result.Select(x => new CrossValidationResult(x.Model, Evaluate(x.Scores, labelColumn), x.Scores, x.Fold)).ToArray(); } } diff --git a/src/Microsoft.ML.Data/Training/TrainerUtils.cs b/src/Microsoft.ML.Data/Training/TrainerUtils.cs index 47540fa68a..92ea25a340 100644 --- a/src/Microsoft.ML.Data/Training/TrainerUtils.cs +++ b/src/Microsoft.ML.Data/Training/TrainerUtils.cs @@ -135,7 +135,7 @@ public static void CheckRegressionLabel(this RoleMappedData data) /// key type, it must have known cardinality. For other numeric types, this scans the data /// to determine the cardinality. /// - public static void CheckMultiClassLabel(this RoleMappedData data, out int count) + public static void CheckMulticlassLabel(this RoleMappedData data, out int count) { Contracts.CheckValue(data, nameof(data)); @@ -948,7 +948,7 @@ protected override FloatLabelCursor CreateCursorCore(DataViewRowCursor input, Ro /// enforcing multi-class semantics. /// [BestFriend] - internal class MultiClassLabelCursor : FeatureFloatVectorCursor + internal class MulticlassLabelCursor : FeatureFloatVectorCursor { private readonly int _classCount; private readonly ValueGetter _get; @@ -959,13 +959,13 @@ internal class MultiClassLabelCursor : FeatureFloatVectorCursor private float _raw; public int Label; - public MultiClassLabelCursor(int classCount, RoleMappedData data, CursOpt opt = CursOpt.Label, + public MulticlassLabelCursor(int classCount, RoleMappedData data, CursOpt opt = CursOpt.Label, Random rand = null, params int[] extraCols) : this(classCount, CreateCursor(data, opt, rand, extraCols), data, opt) { } - protected MultiClassLabelCursor(int classCount, DataViewRowCursor input, RoleMappedData data, CursOpt opt, Action signal = null) + protected MulticlassLabelCursor(int classCount, DataViewRowCursor input, RoleMappedData data, CursOpt opt, Action signal = null) : base(input, data, opt, signal) { Contracts.Assert(classCount >= 0); @@ -1002,7 +1002,7 @@ public override bool Accept() return base.Accept(); } - public new sealed class Factory : FactoryBase + public new sealed class Factory : FactoryBase { private readonly int _classCount; @@ -1014,9 +1014,9 @@ public Factory(int classCount, RoleMappedData data, CursOpt opt = CursOpt.Label) _classCount = classCount; } - protected override MultiClassLabelCursor CreateCursorCore(DataViewRowCursor input, RoleMappedData data, CursOpt opt, Action signal) + protected override MulticlassLabelCursor CreateCursorCore(DataViewRowCursor input, RoleMappedData data, CursOpt opt, Action signal) { - return new MultiClassLabelCursor(_classCount, input, data, opt, signal); + return new MulticlassLabelCursor(_classCount, input, data, opt, signal); } } } diff --git a/src/Microsoft.ML.Ensemble/EntryPoints/CreateEnsemble.cs b/src/Microsoft.ML.Ensemble/EntryPoints/CreateEnsemble.cs index da390fe79f..756e7680a6 100644 --- a/src/Microsoft.ML.Ensemble/EntryPoints/CreateEnsemble.cs +++ b/src/Microsoft.ML.Ensemble/EntryPoints/CreateEnsemble.cs @@ -248,7 +248,7 @@ public static CommonOutputs.RegressionOutput CreateRegressionPipelineEnsemble(IH } [TlcModule.EntryPoint(Name = "Models.MultiClassPipelineEnsemble", Desc = "Combine multiclass classifiers into an ensemble")] - public static CommonOutputs.MulticlassClassificationOutput CreateMultiClassPipelineEnsemble(IHostEnvironment env, PipelineClassifierInput input) + public static CommonOutputs.MulticlassClassificationOutput CreateMulticlassPipelineEnsemble(IHostEnvironment env, PipelineClassifierInput input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("CombineModels"); @@ -270,7 +270,7 @@ public static CommonOutputs.MulticlassClassificationOutput CreateMultiClassPipel default: throw host.Except("Unknown combiner kind"); } - var ensemble = SchemaBindablePipelineEnsembleBase.Create(host, input.Models, combiner, AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification); + var ensemble = SchemaBindablePipelineEnsembleBase.Create(host, input.Models, combiner, AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification); return CreatePipelineEnsemble(host, input.Models, ensemble); } diff --git a/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs b/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs index f649705b2d..1f26740965 100644 --- a/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs +++ b/src/Microsoft.ML.Ensemble/EntryPoints/Ensemble.cs @@ -27,7 +27,7 @@ public static CommonOutputs.BinaryClassificationOutput CreateBinaryEnsemble(IHos } [TlcModule.EntryPoint(Name = "Trainers.EnsembleClassification", Desc = "Train multiclass ensemble.", UserName = EnsembleTrainer.UserNameValue)] - public static CommonOutputs.MulticlassClassificationOutput CreateMultiClassEnsemble(IHostEnvironment env, MulticlassDataPartitionEnsembleTrainer.Arguments input) + public static CommonOutputs.MulticlassClassificationOutput CreateMulticlassEnsemble(IHostEnvironment env, MulticlassDataPartitionEnsembleTrainer.Arguments input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainMultiClassEnsemble"); diff --git a/src/Microsoft.ML.Ensemble/EntryPoints/OutputCombiner.cs b/src/Microsoft.ML.Ensemble/EntryPoints/OutputCombiner.cs index 543a088d8b..f69c1ecdeb 100644 --- a/src/Microsoft.ML.Ensemble/EntryPoints/OutputCombiner.cs +++ b/src/Microsoft.ML.Ensemble/EntryPoints/OutputCombiner.cs @@ -45,6 +45,6 @@ internal sealed class VotingFactory : ISupportBinaryOutputCombinerFactory [TlcModule.Component(Name = MultiVoting.LoadName, FriendlyName = Voting.UserName)] internal sealed class MultiVotingFactory : ISupportMulticlassOutputCombinerFactory { - public IMultiClassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiVoting(env); + public IMulticlassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiVoting(env); } } diff --git a/src/Microsoft.ML.Ensemble/EntryPoints/SubModelSelector.cs b/src/Microsoft.ML.Ensemble/EntryPoints/SubModelSelector.cs index 53ce5f4b53..43ec566149 100644 --- a/src/Microsoft.ML.Ensemble/EntryPoints/SubModelSelector.cs +++ b/src/Microsoft.ML.Ensemble/EntryPoints/SubModelSelector.cs @@ -7,13 +7,13 @@ using Microsoft.ML.Trainers.Ensemble; [assembly: EntryPointModule(typeof(AllSelectorFactory))] -[assembly: EntryPointModule(typeof(AllSelectorMultiClassFactory))] +[assembly: EntryPointModule(typeof(AllSelectorMulticlassFactory))] [assembly: EntryPointModule(typeof(BestDiverseSelectorBinary))] -[assembly: EntryPointModule(typeof(BestDiverseSelectorMultiClass))] +[assembly: EntryPointModule(typeof(BestDiverseSelectorMulticlass))] [assembly: EntryPointModule(typeof(BestDiverseSelectorRegression))] [assembly: EntryPointModule(typeof(BestPerformanceRegressionSelector))] [assembly: EntryPointModule(typeof(BestPerformanceSelector))] -[assembly: EntryPointModule(typeof(BestPerformanceSelectorMultiClass))] +[assembly: EntryPointModule(typeof(BestPerformanceSelectorMulticlass))] namespace Microsoft.ML.Trainers.Ensemble { @@ -25,9 +25,9 @@ internal sealed class AllSelectorFactory : ISupportBinarySubModelSelectorFactory IRegressionSubModelSelector IComponentFactory.CreateComponent(IHostEnvironment env) => new AllSelector(env); } - [TlcModule.Component(Name = AllSelectorMultiClass.LoadName, FriendlyName = AllSelectorMultiClass.UserName)] - internal sealed class AllSelectorMultiClassFactory : ISupportMulticlassSubModelSelectorFactory + [TlcModule.Component(Name = AllSelectorMulticlass.LoadName, FriendlyName = AllSelectorMulticlass.UserName)] + internal sealed class AllSelectorMulticlassFactory : ISupportMulticlassSubModelSelectorFactory { - IMulticlassSubModelSelector IComponentFactory.CreateComponent(IHostEnvironment env) => new AllSelectorMultiClass(env); + IMulticlassSubModelSelector IComponentFactory.CreateComponent(IHostEnvironment env) => new AllSelectorMulticlass(env); } } diff --git a/src/Microsoft.ML.Ensemble/OutputCombiners/BaseMultiCombiner.cs b/src/Microsoft.ML.Ensemble/OutputCombiners/BaseMultiCombiner.cs index a8e8b3441b..70ceb89627 100644 --- a/src/Microsoft.ML.Ensemble/OutputCombiners/BaseMultiCombiner.cs +++ b/src/Microsoft.ML.Ensemble/OutputCombiners/BaseMultiCombiner.cs @@ -11,7 +11,7 @@ namespace Microsoft.ML.Trainers.Ensemble { - internal abstract class BaseMultiCombiner : IMultiClassOutputCombiner, ICanSaveModel + internal abstract class BaseMultiCombiner : IMulticlassOutputCombiner, ICanSaveModel { protected readonly IHost Host; diff --git a/src/Microsoft.ML.Ensemble/OutputCombiners/IOutputCombiner.cs b/src/Microsoft.ML.Ensemble/OutputCombiners/IOutputCombiner.cs index 624191934d..8f78a02cb1 100644 --- a/src/Microsoft.ML.Ensemble/OutputCombiners/IOutputCombiner.cs +++ b/src/Microsoft.ML.Ensemble/OutputCombiners/IOutputCombiner.cs @@ -43,12 +43,12 @@ internal interface IBinaryOutputCombiner : IOutputCombiner { } - internal interface IMultiClassOutputCombiner : IOutputCombiner> + internal interface IMulticlassOutputCombiner : IOutputCombiner> { } [TlcModule.ComponentKind("EnsembleMulticlassOutputCombiner")] - internal interface ISupportMulticlassOutputCombinerFactory : IComponentFactory + internal interface ISupportMulticlassOutputCombinerFactory : IComponentFactory { } diff --git a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiAverage.cs b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiAverage.cs index 0bc9ee410e..ac56b23d7a 100644 --- a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiAverage.cs +++ b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiAverage.cs @@ -35,7 +35,7 @@ private static VersionInfo GetVersionInfo() [TlcModule.Component(Name = LoadName, FriendlyName = Average.UserName)] public sealed class Options : OptionsBase, ISupportMulticlassOutputCombinerFactory { - public IMultiClassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiAverage(env, this); + public IMulticlassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiAverage(env, this); } public MultiAverage(IHostEnvironment env, Options options) diff --git a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiMedian.cs b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiMedian.cs index d9899aa433..6a2de37bbb 100644 --- a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiMedian.cs +++ b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiMedian.cs @@ -38,7 +38,7 @@ private static VersionInfo GetVersionInfo() [TlcModule.Component(Name = LoadName, FriendlyName = Median.UserName)] public sealed class Options : OptionsBase, ISupportMulticlassOutputCombinerFactory { - public IMultiClassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiMedian(env, this); + public IMulticlassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiMedian(env, this); } public MultiMedian(IHostEnvironment env, Options options) diff --git a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiStacking.cs b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiStacking.cs index 512bbbbdbf..dcf2b47805 100644 --- a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiStacking.cs +++ b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiStacking.cs @@ -20,7 +20,7 @@ namespace Microsoft.ML.Trainers.Ensemble { using TVectorPredictor = IPredictorProducing>; - internal sealed class MultiStacking : BaseStacking>, IMultiClassOutputCombiner + internal sealed class MultiStacking : BaseStacking>, IMulticlassOutputCombiner { public const string LoadName = "MultiStacking"; public const string LoaderSignature = "MultiStackingCombiner"; @@ -42,13 +42,13 @@ public sealed class Arguments : ArgumentsBase, ISupportMulticlassOutputCombinerF { // REVIEW: If we make this public again it should be an *estimator* of this type of predictor, rather than the (deprecated) ITrainer. [Argument(ArgumentType.Multiple, HelpText = "Base predictor for meta learning", ShortName = "bp", SortOrder = 50, - Visibility = ArgumentAttribute.VisibilityType.CmdLineOnly, SignatureType = typeof(SignatureMultiClassClassifierTrainer))] + Visibility = ArgumentAttribute.VisibilityType.CmdLineOnly, SignatureType = typeof(SignatureMulticlassClassifierTrainer))] [TGUI(Label = "Base predictor")] public IComponentFactory> BasePredictorType; internal override IComponentFactory> GetPredictorFactory() => BasePredictorType; - public IMultiClassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiStacking(env, this); + public IMulticlassOutputCombiner CreateComponent(IHostEnvironment env) => new MultiStacking(env, this); } #pragma warning restore CS0649 diff --git a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiWeightedAverage.cs b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiWeightedAverage.cs index d0c92f38bb..731347aad2 100644 --- a/src/Microsoft.ML.Ensemble/OutputCombiners/MultiWeightedAverage.cs +++ b/src/Microsoft.ML.Ensemble/OutputCombiners/MultiWeightedAverage.cs @@ -42,7 +42,7 @@ private static VersionInfo GetVersionInfo() [TlcModule.Component(Name = LoadName, FriendlyName = UserName)] public sealed class Options : OptionsBase, ISupportMulticlassOutputCombinerFactory { - IMultiClassOutputCombiner IComponentFactory.CreateComponent(IHostEnvironment env) => new MultiWeightedAverage(env, this); + IMulticlassOutputCombiner IComponentFactory.CreateComponent(IHostEnvironment env) => new MultiWeightedAverage(env, this); [Argument(ArgumentType.AtMostOnce, HelpText = "The metric type to be used to find the weights for each model", ShortName = "wn", SortOrder = 50)] [TGUI(Label = "Metric Name", Description = "The weights are calculated according to the selected metric")] @@ -97,9 +97,9 @@ public override Combiner> GetCombiner() // These values are serialized, so should not be changed. internal enum MultiWeightageKind { - [TGUI(Label = MultiClassClassifierEvaluator.AccuracyMicro)] + [TGUI(Label = MulticlassClassificationEvaluator.AccuracyMicro)] AccuracyMicroAvg = 0, - [TGUI(Label = MultiClassClassifierEvaluator.AccuracyMacro)] + [TGUI(Label = MulticlassClassificationEvaluator.AccuracyMacro)] AccuracyMacroAvg = 1 } } diff --git a/src/Microsoft.ML.Ensemble/PipelineEnsemble.cs b/src/Microsoft.ML.Ensemble/PipelineEnsemble.cs index a24ba16bcc..57689c3a3c 100644 --- a/src/Microsoft.ML.Ensemble/PipelineEnsemble.cs +++ b/src/Microsoft.ML.Ensemble/PipelineEnsemble.cs @@ -266,16 +266,16 @@ public override PredictionKind PredictionKind { get { - if (_scoreColumnKind == AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification) - return PredictionKind.MultiClassClassification; + if (_scoreColumnKind == AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification) + return PredictionKind.MulticlassClassification; throw Host.Except("Unknown prediction kind"); } } private readonly VectorType _scoreType; - public ImplVec(IHostEnvironment env, PredictorModel[] predictors, IMultiClassOutputCombiner combiner) - : base(env, predictors, combiner, LoaderSignature, AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification) + public ImplVec(IHostEnvironment env, PredictorModel[] predictors, IMulticlassOutputCombiner combiner) + : base(env, predictors, combiner, LoaderSignature, AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification) { int classCount = CheckLabelColumn(Host, predictors, false); _scoreType = new VectorType(NumberDataViewType.Single, classCount); @@ -532,8 +532,8 @@ public static SchemaBindablePipelineEnsembleBase Create(IHostEnvironment env, Pr if (regressionCombiner == null) throw env.Except("Combiner type incompatible with score column kind"); return new ImplOne(env, predictors, regressionCombiner, scoreColumnKind); - case AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification: - var vectorCombiner = combiner as IMultiClassOutputCombiner; + case AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification: + var vectorCombiner = combiner as IMulticlassOutputCombiner; if (vectorCombiner == null) throw env.Except("Combiner type incompatible with score column kind"); return new ImplVec(env, predictors, vectorCombiner); @@ -556,7 +556,7 @@ public static SchemaBindablePipelineEnsembleBase Create(IHostEnvironment env, Mo case AnnotationUtils.Const.ScoreColumnKind.Regression: case AnnotationUtils.Const.ScoreColumnKind.AnomalyDetection: return new ImplOne(env, ctx, scoreColumnKind); - case AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification: + case AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification: return new ImplVec(env, ctx, scoreColumnKind); default: throw env.Except("Unknown score kind"); diff --git a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/AllSelectorMultiClass.cs b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/AllSelectorMulticlass.cs similarity index 73% rename from src/Microsoft.ML.Ensemble/Selector/SubModelSelector/AllSelectorMultiClass.cs rename to src/Microsoft.ML.Ensemble/Selector/SubModelSelector/AllSelectorMulticlass.cs index 672090073e..87147eb283 100644 --- a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/AllSelectorMultiClass.cs +++ b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/AllSelectorMulticlass.cs @@ -8,21 +8,21 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.Ensemble; -[assembly: LoadableClass(typeof(AllSelectorMultiClass), null, typeof(SignatureEnsembleSubModelSelector), - AllSelectorMultiClass.UserName, AllSelectorMultiClass.LoadName)] +[assembly: LoadableClass(typeof(AllSelectorMulticlass), null, typeof(SignatureEnsembleSubModelSelector), + AllSelectorMulticlass.UserName, AllSelectorMulticlass.LoadName)] namespace Microsoft.ML.Trainers.Ensemble { - internal sealed class AllSelectorMultiClass : BaseSubModelSelector>, IMulticlassSubModelSelector + internal sealed class AllSelectorMulticlass : BaseSubModelSelector>, IMulticlassSubModelSelector { public const string UserName = "All Selector"; public const string LoadName = "AllSelectorMultiClass"; public override Single ValidationDatasetProportion => 0; - protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; - public AllSelectorMultiClass(IHostEnvironment env) + public AllSelectorMulticlass(IHostEnvironment env) : base(env, LoadName) { } diff --git a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BaseSubModelSelector.cs b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BaseSubModelSelector.cs index a32fd6733a..22acd34d39 100644 --- a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BaseSubModelSelector.cs +++ b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BaseSubModelSelector.cs @@ -63,8 +63,8 @@ private IEvaluator GetEvaluator(IHostEnvironment env) return new BinaryClassifierEvaluator(env, new BinaryClassifierEvaluator.Arguments()); case PredictionKind.Regression: return new RegressionEvaluator(env, new RegressionEvaluator.Arguments()); - case PredictionKind.MultiClassClassification: - return new MultiClassClassifierEvaluator(env, new MultiClassClassifierEvaluator.Arguments()); + case PredictionKind.MulticlassClassification: + return new MulticlassClassificationEvaluator(env, new MulticlassClassificationEvaluator.Arguments()); default: throw Host.Except("Unrecognized prediction kind '{0}'", PredictionKind); } @@ -122,10 +122,10 @@ public virtual void CalculateMetrics(FeatureSubsetModel model, AnnotationUtils.Const.ScoreColumnKind.Regression); yield return RoleMappedSchema.CreatePair(AnnotationUtils.Const.ScoreValueKind.Score, scoreCol.Name); yield break; - case PredictionKind.MultiClassClassification: + case PredictionKind.MulticlassClassification: yield return RoleMappedSchema.CreatePair(RoleMappedSchema.ColumnRole.Label, testSchema.Label.Value.Name); - scoreCol = EvaluateUtils.GetScoreColumn(Host, scoredSchema, null, nameof(MultiClassMamlEvaluator.Arguments.ScoreColumn), - AnnotationUtils.Const.ScoreColumnKind.MultiClassClassification); + scoreCol = EvaluateUtils.GetScoreColumn(Host, scoredSchema, null, nameof(MulticlassClassificationMamlEvaluator.Arguments.ScoreColumn), + AnnotationUtils.Const.ScoreColumnKind.MulticlassClassification); yield return RoleMappedSchema.CreatePair(AnnotationUtils.Const.ScoreValueKind.Score, scoreCol.Name); yield break; default: diff --git a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestDiverseSelectorMultiClass.cs b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestDiverseSelectorMulticlass.cs similarity index 84% rename from src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestDiverseSelectorMultiClass.cs rename to src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestDiverseSelectorMulticlass.cs index 21cce5f428..08ba5c309e 100644 --- a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestDiverseSelectorMultiClass.cs +++ b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestDiverseSelectorMulticlass.cs @@ -13,12 +13,12 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.Ensemble; -[assembly: LoadableClass(typeof(BestDiverseSelectorMultiClass), typeof(BestDiverseSelectorMultiClass.Arguments), - typeof(SignatureEnsembleSubModelSelector), BestDiverseSelectorMultiClass.UserName, BestDiverseSelectorMultiClass.LoadName)] +[assembly: LoadableClass(typeof(BestDiverseSelectorMulticlass), typeof(BestDiverseSelectorMulticlass.Arguments), + typeof(SignatureEnsembleSubModelSelector), BestDiverseSelectorMulticlass.UserName, BestDiverseSelectorMulticlass.LoadName)] namespace Microsoft.ML.Trainers.Ensemble { - internal sealed class BestDiverseSelectorMultiClass : BaseDiverseSelector, IDiversityMeasure>>, IMulticlassSubModelSelector + internal sealed class BestDiverseSelectorMulticlass : BaseDiverseSelector, IDiversityMeasure>>, IMulticlassSubModelSelector { public const string UserName = "Best Diverse Selector"; public const string LoadName = "BestDiverseSelectorMultiClass"; @@ -29,15 +29,15 @@ public sealed class Arguments : DiverseSelectorArguments, ISupportMulticlassSubM [Argument(ArgumentType.Multiple, HelpText = "The metric type to be used to find the diversity among base learners", ShortName = "dm", SortOrder = 50)] [TGUI(Label = "Diversity Measure Type")] public ISupportMulticlassDiversityMeasureFactory DiversityMetricType = new MultiDisagreementDiversityFactory(); - public IMulticlassSubModelSelector CreateComponent(IHostEnvironment env) => new BestDiverseSelectorMultiClass(env, this); + public IMulticlassSubModelSelector CreateComponent(IHostEnvironment env) => new BestDiverseSelectorMulticlass(env, this); } - public BestDiverseSelectorMultiClass(IHostEnvironment env, Arguments args) + public BestDiverseSelectorMulticlass(IHostEnvironment env, Arguments args) : base(env, args, LoadName, args.DiversityMetricType) { } - protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; public override List>> CalculateDiversityMeasure(IList>> models, ConcurrentDictionary>, VBuffer[]> predictions) diff --git a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestPerformanceSelectorMultiClass.cs b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestPerformanceSelectorMulticlass.cs similarity index 64% rename from src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestPerformanceSelectorMultiClass.cs rename to src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestPerformanceSelectorMulticlass.cs index acdef8118d..7b8989b06f 100644 --- a/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestPerformanceSelectorMultiClass.cs +++ b/src/Microsoft.ML.Ensemble/Selector/SubModelSelector/BestPerformanceSelectorMulticlass.cs @@ -11,42 +11,42 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.Ensemble; -[assembly: LoadableClass(typeof(BestPerformanceSelectorMultiClass), typeof(BestPerformanceSelectorMultiClass.Arguments), - typeof(SignatureEnsembleSubModelSelector), BestPerformanceSelectorMultiClass.UserName, BestPerformanceSelectorMultiClass.LoadName)] +[assembly: LoadableClass(typeof(BestPerformanceSelectorMulticlass), typeof(BestPerformanceSelectorMulticlass.Arguments), + typeof(SignatureEnsembleSubModelSelector), BestPerformanceSelectorMulticlass.UserName, BestPerformanceSelectorMulticlass.LoadName)] namespace Microsoft.ML.Trainers.Ensemble { - internal sealed class BestPerformanceSelectorMultiClass : BaseBestPerformanceSelector>, IMulticlassSubModelSelector + internal sealed class BestPerformanceSelectorMulticlass : BaseBestPerformanceSelector>, IMulticlassSubModelSelector { [TlcModule.Component(Name = LoadName, FriendlyName = UserName)] public sealed class Arguments : ArgumentsBase, ISupportMulticlassSubModelSelectorFactory { [Argument(ArgumentType.AtMostOnce, HelpText = "The metric type to be used to find the best performance", ShortName = "mn", SortOrder = 50)] [TGUI(Label = "Metric Name")] - public MultiClassClassifierEvaluator.Metrics MetricName = MultiClassClassifierEvaluator.Metrics.AccuracyMicro; + public MulticlassClassificationEvaluator.Metrics MetricName = MulticlassClassificationEvaluator.Metrics.AccuracyMicro; - IMulticlassSubModelSelector IComponentFactory.CreateComponent(IHostEnvironment env) => new BestPerformanceSelectorMultiClass(env, this); + IMulticlassSubModelSelector IComponentFactory.CreateComponent(IHostEnvironment env) => new BestPerformanceSelectorMulticlass(env, this); } public const string UserName = "Best Performance Selector"; public const string LoadName = "BestPerformanceSelectorMultiClass"; - private readonly MultiClassClassifierEvaluator.Metrics _metric; + private readonly MulticlassClassificationEvaluator.Metrics _metric; private readonly string _metricName; - public BestPerformanceSelectorMultiClass(IHostEnvironment env, Arguments args) + public BestPerformanceSelectorMulticlass(IHostEnvironment env, Arguments args) : base(args, env, LoadName) { - Host.CheckUserArg(Enum.IsDefined(typeof(MultiClassClassifierEvaluator.Metrics), args.MetricName), + Host.CheckUserArg(Enum.IsDefined(typeof(MulticlassClassificationEvaluator.Metrics), args.MetricName), nameof(args.MetricName), "Undefined metric name"); _metric = args.MetricName; - _metricName = FindMetricName(typeof(MultiClassClassifierEvaluator.Metrics), _metric); + _metricName = FindMetricName(typeof(MulticlassClassificationEvaluator.Metrics), _metric); Host.Assert(!string.IsNullOrEmpty(_metricName)); } - protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; - protected override bool IsAscMetric => _metric != MultiClassClassifierEvaluator.Metrics.LogLoss; + protected override bool IsAscMetric => _metric != MulticlassClassificationEvaluator.Metrics.LogLoss; protected override string MetricName => _metricName; } diff --git a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/EnsembleMultiClassModelParameters.cs b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/EnsembleMulticlassModelParameters.cs similarity index 91% rename from src/Microsoft.ML.Ensemble/Trainer/Multiclass/EnsembleMultiClassModelParameters.cs rename to src/Microsoft.ML.Ensemble/Trainer/Multiclass/EnsembleMulticlassModelParameters.cs index 813d54a60a..0b7a38e1db 100644 --- a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/EnsembleMultiClassModelParameters.cs +++ b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/EnsembleMulticlassModelParameters.cs @@ -10,12 +10,12 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.Ensemble; -[assembly: LoadableClass(typeof(EnsembleMultiClassModelParameters), null, typeof(SignatureLoadModel), - EnsembleMultiClassModelParameters.UserName, EnsembleMultiClassModelParameters.LoaderSignature)] +[assembly: LoadableClass(typeof(EnsembleMulticlassModelParameters), null, typeof(SignatureLoadModel), + EnsembleMulticlassModelParameters.UserName, EnsembleMulticlassModelParameters.LoaderSignature)] namespace Microsoft.ML.Trainers.Ensemble { - internal sealed class EnsembleMultiClassModelParameters : EnsembleModelParametersBase>, IValueMapper + internal sealed class EnsembleMulticlassModelParameters : EnsembleModelParametersBase>, IValueMapper { internal const string UserName = "Ensemble Multiclass Executor"; internal const string LoaderSignature = "EnsemMcExec"; @@ -31,7 +31,7 @@ private static VersionInfo GetVersionInfo() verReadableCur: 0x00010003, verWeCanReadBack: 0x00010002, loaderSignature: LoaderSignature, - loaderAssemblyName: typeof(EnsembleMultiClassModelParameters).Assembly.FullName); + loaderAssemblyName: typeof(EnsembleMulticlassModelParameters).Assembly.FullName); } private readonly VectorType _inputType; @@ -48,14 +48,14 @@ private static VersionInfo GetVersionInfo() /// Array of sub-models that you want to ensemble together. /// The combiner class to use to ensemble the models. /// The weights assigned to each model to be ensembled. - internal EnsembleMultiClassModelParameters(IHostEnvironment env, FeatureSubsetModel>[] models, - IMultiClassOutputCombiner combiner, Single[] weights = null) + internal EnsembleMulticlassModelParameters(IHostEnvironment env, FeatureSubsetModel>[] models, + IMulticlassOutputCombiner combiner, Single[] weights = null) : base(env, RegistrationName, models, combiner, weights) { InitializeMappers(out _mappers, out _inputType, out _outputType); } - private EnsembleMultiClassModelParameters(IHostEnvironment env, ModelLoadContext ctx) + private EnsembleMulticlassModelParameters(IHostEnvironment env, ModelLoadContext ctx) : base(env, RegistrationName, ctx) { InitializeMappers(out _mappers, out _inputType, out _outputType); @@ -92,12 +92,12 @@ private void InitializeMappers(out IValueMapper[] mappers, out VectorType inputT inputType = new VectorType(NumberDataViewType.Single); } - private static EnsembleMultiClassModelParameters Create(IHostEnvironment env, ModelLoadContext ctx) + private static EnsembleMulticlassModelParameters Create(IHostEnvironment env, ModelLoadContext ctx) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(ctx, nameof(ctx)); ctx.CheckAtModel(GetVersionInfo()); - return new EnsembleMultiClassModelParameters(env, ctx); + return new EnsembleMulticlassModelParameters(env, ctx); } private protected override void SaveCore(ModelSaveContext ctx) @@ -106,7 +106,7 @@ private protected override void SaveCore(ModelSaveContext ctx) ctx.SetVersionInfo(GetVersionInfo()); } - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; ValueMapper IValueMapper.GetMapper() { diff --git a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs index 526f23729a..9946cc66e5 100644 --- a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs +++ b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs @@ -14,7 +14,7 @@ [assembly: LoadableClass(MulticlassDataPartitionEnsembleTrainer.Summary, typeof(MulticlassDataPartitionEnsembleTrainer), typeof(MulticlassDataPartitionEnsembleTrainer.Arguments), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer) }, MulticlassDataPartitionEnsembleTrainer.UserNameValue, MulticlassDataPartitionEnsembleTrainer.LoadNameValue)] @@ -28,8 +28,8 @@ namespace Microsoft.ML.Trainers.Ensemble /// A generic ensemble classifier for multi-class classification /// internal sealed class MulticlassDataPartitionEnsembleTrainer : - EnsembleTrainerBase, EnsembleMultiClassModelParameters, - IMulticlassSubModelSelector, IMultiClassOutputCombiner>, + EnsembleTrainerBase, EnsembleMulticlassModelParameters, + IMulticlassSubModelSelector, IMulticlassOutputCombiner>, IModelCombiner { public const string LoadNameValue = "WeightedEnsembleMulticlass"; @@ -40,14 +40,14 @@ public sealed class Arguments : ArgumentsBase { [Argument(ArgumentType.Multiple, HelpText = "Algorithm to prune the base learners for selective Ensemble", ShortName = "pt", SortOrder = 4)] [TGUI(Label = "Sub-Model Selector(pruning) Type", Description = "Algorithm to prune the base learners for selective Ensemble")] - public ISupportMulticlassSubModelSelectorFactory SubModelSelectorType = new AllSelectorMultiClassFactory(); + public ISupportMulticlassSubModelSelectorFactory SubModelSelectorType = new AllSelectorMulticlassFactory(); [Argument(ArgumentType.Multiple, HelpText = "Output combiner", ShortName = "oc", SortOrder = 5)] [TGUI(Label = "Output combiner", Description = "Output combiner type")] public ISupportMulticlassOutputCombinerFactory OutputCombiner = new MultiMedian.Options(); // REVIEW: If we make this public again it should be an *estimator* of this type of predictor, rather than the (deprecated) ITrainer. - [Argument(ArgumentType.Multiple, HelpText = "Base predictor type", ShortName = "bp,basePredictorTypes", SortOrder = 1, Visibility = ArgumentAttribute.VisibilityType.CmdLineOnly, SignatureType = typeof(SignatureMultiClassClassifierTrainer))] + [Argument(ArgumentType.Multiple, HelpText = "Base predictor type", ShortName = "bp,basePredictorTypes", SortOrder = 1, Visibility = ArgumentAttribute.VisibilityType.CmdLineOnly, SignatureType = typeof(SignatureMulticlassClassifierTrainer))] internal IComponentFactory>[] BasePredictors; internal override IComponentFactory>[] GetPredictorFactories() => BasePredictors; @@ -85,14 +85,14 @@ public MulticlassDataPartitionEnsembleTrainer(IHostEnvironment env, Arguments ar private MulticlassDataPartitionEnsembleTrainer(IHostEnvironment env, Arguments args, PredictionKind predictionKind) : this(env, args) { - Host.CheckParam(predictionKind == PredictionKind.MultiClassClassification, nameof(PredictionKind)); + Host.CheckParam(predictionKind == PredictionKind.MulticlassClassification, nameof(PredictionKind)); } - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; - private protected override EnsembleMultiClassModelParameters CreatePredictor(List>> models) + private protected override EnsembleMulticlassModelParameters CreatePredictor(List>> models) { - return new EnsembleMultiClassModelParameters(Host, CreateModels(models), Combiner as IMultiClassOutputCombiner); + return new EnsembleMulticlassModelParameters(Host, CreateModels(models), Combiner as IMulticlassOutputCombiner); } public IPredictor CombineModels(IEnumerable models) @@ -101,7 +101,7 @@ public IPredictor CombineModels(IEnumerable models) Host.CheckParam(models.All(m => m is TVectorPredictor), nameof(models)); var combiner = _outputCombiner.CreateComponent(Host); - var predictor = new EnsembleMultiClassModelParameters(Host, + var predictor = new EnsembleMulticlassModelParameters(Host, models.Select(k => new FeatureSubsetModel>((TVectorPredictor)k)).ToArray(), combiner); return predictor; diff --git a/src/Microsoft.ML.EntryPoints/CrossValidationMacro.cs b/src/Microsoft.ML.EntryPoints/CrossValidationMacro.cs index 9486c1cb03..da9965ff5e 100644 --- a/src/Microsoft.ML.EntryPoints/CrossValidationMacro.cs +++ b/src/Microsoft.ML.EntryPoints/CrossValidationMacro.cs @@ -302,7 +302,7 @@ public static CommonOutputs.MacroOutput CrossValidate( MacroUtils.ConvertIdataViewsToArray(env, node.Context, subGraphNodes, overallMetricsVars, overallArrayVar.VarName); MacroUtils.ConvertIdataViewsToArray(env, node.Context, subGraphNodes, instanceMetricsVars, instanceArrayVar.VarName); if (input.Kind == MacroUtils.TrainerKinds.SignatureBinaryClassifierTrainer || - input.Kind == MacroUtils.TrainerKinds.SignatureMultiClassClassifierTrainer) + input.Kind == MacroUtils.TrainerKinds.SignatureMulticlassClassificationTrainer) { confusionMatrixArrayVar = new ArrayVar(); MacroUtils.ConvertIdataViewsToArray(env, node.Context, subGraphNodes, confusionMatrixVars, confusionMatrixArrayVar.VarName); @@ -426,8 +426,8 @@ private static IMamlEvaluator GetEvaluator(IHostEnvironment env, MacroUtils.Trai { case MacroUtils.TrainerKinds.SignatureBinaryClassifierTrainer: return new BinaryClassifierMamlEvaluator(env, new BinaryClassifierMamlEvaluator.Arguments()); - case MacroUtils.TrainerKinds.SignatureMultiClassClassifierTrainer: - return new MultiClassMamlEvaluator(env, new MultiClassMamlEvaluator.Arguments()); + case MacroUtils.TrainerKinds.SignatureMulticlassClassificationTrainer: + return new MulticlassClassificationMamlEvaluator(env, new MulticlassClassificationMamlEvaluator.Arguments()); case MacroUtils.TrainerKinds.SignatureRegressorTrainer: return new RegressionMamlEvaluator(env, new RegressionMamlEvaluator.Arguments()); case MacroUtils.TrainerKinds.SignatureRankerTrainer: diff --git a/src/Microsoft.ML.EntryPoints/MacroUtils.cs b/src/Microsoft.ML.EntryPoints/MacroUtils.cs index 87a8cd7b22..61f7edf29f 100644 --- a/src/Microsoft.ML.EntryPoints/MacroUtils.cs +++ b/src/Microsoft.ML.EntryPoints/MacroUtils.cs @@ -22,7 +22,7 @@ internal static class MacroUtils public enum TrainerKinds { SignatureBinaryClassifierTrainer, - SignatureMultiClassClassifierTrainer, + SignatureMulticlassClassificationTrainer, SignatureRankerTrainer, SignatureRegressorTrainer, SignatureMultiOutputRegressorTrainer, @@ -51,9 +51,9 @@ public static EvaluateInputBase GetEvaluatorArgs(TrainerKinds kind, out string e case TrainerKinds.SignatureBinaryClassifierTrainer: entryPointName = "Models.BinaryClassificationEvaluator"; return new BinaryClassifierMamlEvaluator.Arguments() { LabelColumn = settings.LabelColumn, WeightColumn = settings.WeightColumn, NameColumn = settings.NameColumn }; - case TrainerKinds.SignatureMultiClassClassifierTrainer: + case TrainerKinds.SignatureMulticlassClassificationTrainer: entryPointName = "Models.ClassificationEvaluator"; - return new MultiClassMamlEvaluator.Arguments() { LabelColumn = settings.LabelColumn, WeightColumn = settings.WeightColumn, NameColumn = settings.NameColumn }; + return new MulticlassClassificationMamlEvaluator.Arguments() { LabelColumn = settings.LabelColumn, WeightColumn = settings.WeightColumn, NameColumn = settings.NameColumn }; case TrainerKinds.SignatureRankerTrainer: entryPointName = "Models.RankingEvaluator"; return new RankingMamlEvaluator.Arguments() { LabelColumn = settings.LabelColumn, WeightColumn = settings.WeightColumn, NameColumn = settings.NameColumn, GroupIdColumn = settings.GroupColumn }; diff --git a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs index e4867ec74d..e125a2a6b8 100644 --- a/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs +++ b/src/Microsoft.ML.EntryPoints/OneVersusAllMacro.cs @@ -130,7 +130,7 @@ private static int GetNumberOfClasses(IHostEnvironment env, Arguments input, out // Get number of classes var data = new RoleMappedData(input.TrainingData, label, feature, null, weight); - data.CheckMultiClassLabel(out var numClasses); + data.CheckMulticlassLabel(out var numClasses); return numClasses; } } diff --git a/src/Microsoft.ML.LightGbm.StaticPipe/LightGbmStaticExtensions.cs b/src/Microsoft.ML.LightGbm.StaticPipe/LightGbmStaticExtensions.cs index d671ec9767..439cb28a40 100644 --- a/src/Microsoft.ML.LightGbm.StaticPipe/LightGbmStaticExtensions.cs +++ b/src/Microsoft.ML.LightGbm.StaticPipe/LightGbmStaticExtensions.cs @@ -314,7 +314,7 @@ public static (Vector score, Key predictedLabel) { CheckUserValues(label, features, weights, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations, onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { var trainer = new LightGbmMulticlassClassificationTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, @@ -352,7 +352,7 @@ public static (Vector score, Key predictedLabel) { CheckUserValues(label, features, weights, options, onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { options.LabelColumnName = labelName; diff --git a/src/Microsoft.ML.LightGbm/LightGbmMulticlassTrainer.cs b/src/Microsoft.ML.LightGbm/LightGbmMulticlassTrainer.cs index f229b1adc2..8608db15ba 100644 --- a/src/Microsoft.ML.LightGbm/LightGbmMulticlassTrainer.cs +++ b/src/Microsoft.ML.LightGbm/LightGbmMulticlassTrainer.cs @@ -14,7 +14,7 @@ using Microsoft.ML.Trainers.LightGbm; [assembly: LoadableClass(LightGbmMulticlassClassificationTrainer.Summary, typeof(LightGbmMulticlassClassificationTrainer), typeof(Options), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer) }, "LightGBM Multi-class Classifier", LightGbmMulticlassClassificationTrainer.LoadNameValue, LightGbmMulticlassClassificationTrainer.ShortName, DocName = "trainer/LightGBM.md")] namespace Microsoft.ML.Trainers.LightGbm @@ -33,7 +33,7 @@ public sealed class LightGbmMulticlassClassificationTrainer : LightGbmTrainerBas private const double _maxNumClass = 1e6; private int _numClass; private int _tlcNumClass; - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; internal LightGbmMulticlassClassificationTrainer(IHostEnvironment env, Options options) : base(env, LoadNameValue, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) @@ -181,7 +181,7 @@ private protected override void GetDefaultParameters(IChannel ch, int numRow, bo private protected override void CheckAndUpdateParametersBeforeTraining(IChannel ch, RoleMappedData data, float[] labels, int[] groups) { Host.AssertValue(ch); - ch.Assert(PredictionKind == PredictionKind.MultiClassClassification); + ch.Assert(PredictionKind == PredictionKind.MulticlassClassification); ch.Assert(_numClass > 1); Options["num_class"] = _numClass; bool useSoftmax = false; @@ -241,7 +241,7 @@ internal static partial class LightGbm Desc = "Train a LightGBM multi class model.", UserName = LightGbmMulticlassClassificationTrainer.Summary, ShortName = LightGbmMulticlassClassificationTrainer.ShortName)] - public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, Options input) + public static CommonOutputs.MulticlassClassificationOutput TrainMulticlass(IHostEnvironment env, Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainLightGBM"); diff --git a/src/Microsoft.ML.LightGbm/LightGbmTrainerBase.cs b/src/Microsoft.ML.LightGbm/LightGbmTrainerBase.cs index 12ae1e7417..e1992f1b63 100644 --- a/src/Microsoft.ML.LightGbm/LightGbmTrainerBase.cs +++ b/src/Microsoft.ML.LightGbm/LightGbmTrainerBase.cs @@ -363,7 +363,7 @@ private void TrainCore(IChannel ch, IProgressChannel pch, Dataset dtrain, Catego Host.AssertValue(dtrain); Host.AssertValueOrNull(dvalid); // For multi class, the number of labels is required. - ch.Assert(((ITrainer)this).PredictionKind != PredictionKind.MultiClassClassification || Options.ContainsKey("num_class"), + ch.Assert(((ITrainer)this).PredictionKind != PredictionKind.MulticlassClassification || Options.ContainsKey("num_class"), "LightGBM requires the number of classes to be specified in the parameters."); // Only enable one trainer to run at one time. diff --git a/src/Microsoft.ML.SamplesUtils/ConsoleUtils.cs b/src/Microsoft.ML.SamplesUtils/ConsoleUtils.cs index e3e34c3757..4fbb489241 100644 --- a/src/Microsoft.ML.SamplesUtils/ConsoleUtils.cs +++ b/src/Microsoft.ML.SamplesUtils/ConsoleUtils.cs @@ -37,10 +37,10 @@ public static void PrintMetrics(CalibratedBinaryClassificationMetrics metrics) } /// - /// Pretty-print MultiClassClassifierMetrics objects. + /// Pretty-print MulticlassClassificationMetrics objects. /// - /// object. - public static void PrintMetrics(MultiClassClassifierMetrics metrics) + /// object. + public static void PrintMetrics(MulticlassClassificationMetrics metrics) { Console.WriteLine($"Micro Accuracy: {metrics.MicroAccuracy:F2}"); Console.WriteLine($"Macro Accuracy: {metrics.MacroAccuracy:F2}"); diff --git a/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs b/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs index 9b30d907a7..0084504abd 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs @@ -21,7 +21,7 @@ using Newtonsoft.Json.Linq; [assembly: LoadableClass(typeof(LogisticRegressionMulticlassClassificationTrainer), typeof(LogisticRegressionMulticlassClassificationTrainer.Options), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer) }, LogisticRegressionMulticlassClassificationTrainer.UserNameValue, LogisticRegressionMulticlassClassificationTrainer.LoadNameValue, "MulticlassLogisticRegressionPredictorNew", @@ -109,7 +109,7 @@ internal LogisticRegressionMulticlassClassificationTrainer(IHostEnvironment env, ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStatistics; } - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; private protected override void CheckLabel(RoleMappedData data) { @@ -117,7 +117,7 @@ private protected override void CheckLabel(RoleMappedData data) // REVIEW: For floating point labels, this will make a pass over the data. // Should we instead leverage the pass made by the LBFGS base class? Ideally, it wouldn't // make a pass over the data... - data.CheckMultiClassLabel(out _numClasses); + data.CheckMulticlassLabel(out _numClasses); // Initialize prior counts. _prior = new Double[_numClasses]; @@ -387,7 +387,7 @@ private static VersionInfo GetVersionInfo() // at which point it is initialized. private volatile VBuffer[] _weightsDense; - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; internal readonly DataViewType InputType; internal readonly DataViewType OutputType; DataViewType IValueMapper.InputType => InputType; @@ -1011,7 +1011,7 @@ public partial class LogisticRegressionBinaryClassificationTrainer Desc = Summary, UserName = LogisticRegressionMulticlassClassificationTrainer.UserNameValue, ShortName = LogisticRegressionMulticlassClassificationTrainer.ShortName)] - internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, LogisticRegressionMulticlassClassificationTrainer.Options input) + internal static CommonOutputs.MulticlassClassificationOutput TrainMulticlass(IHostEnvironment env, LogisticRegressionMulticlassClassificationTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainLRMultiClass"); diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/MetaMulticlassTrainer.cs similarity index 99% rename from src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs rename to src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/MetaMulticlassTrainer.cs index 70c1d39287..5c935d0272 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/MetaMulticlassTrainer.cs @@ -46,7 +46,7 @@ internal abstract class OptionsBase private protected readonly TScalarTrainer Trainer; PredictionKind ITrainer.PredictionKind => PredictionKind; - private protected PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected PredictionKind PredictionKind => PredictionKind.MulticlassClassification; private protected SchemaShape.Column[] OutputColumns; @@ -123,7 +123,7 @@ IPredictor ITrainer.Train(TrainContext context) data.CheckFeatureFloatVector(); int count; - data.CheckMultiClassLabel(out count); + data.CheckMulticlassLabel(out count); Host.Assert(count > 0); using (var ch = Host.Start("Training")) diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/MulticlassNaiveBayesTrainer.cs similarity index 93% rename from src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs rename to src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/MulticlassNaiveBayesTrainer.cs index d8bcc13bf3..f8bd919835 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/MulticlassNaiveBayesTrainer.cs @@ -15,19 +15,19 @@ using Microsoft.ML.Trainers; [assembly: LoadableClass(NaiveBayesTrainer.Summary, typeof(NaiveBayesTrainer), typeof(NaiveBayesTrainer.Options), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer) }, NaiveBayesTrainer.UserName, NaiveBayesTrainer.LoadName, NaiveBayesTrainer.ShortName, DocName = "trainer/NaiveBayes.md")] -[assembly: LoadableClass(typeof(MultiClassNaiveBayesModelParameters), null, typeof(SignatureLoadModel), - "Multi Class Naive Bayes predictor", MultiClassNaiveBayesModelParameters.LoaderSignature)] +[assembly: LoadableClass(typeof(MulticlassNaiveBayesModelParameters), null, typeof(SignatureLoadModel), + "Multi Class Naive Bayes predictor", MulticlassNaiveBayesModelParameters.LoaderSignature)] [assembly: LoadableClass(typeof(void), typeof(NaiveBayesTrainer), null, typeof(SignatureEntryPointModule), NaiveBayesTrainer.LoadName)] namespace Microsoft.ML.Trainers { - public sealed class NaiveBayesTrainer : TrainerEstimatorBase, MultiClassNaiveBayesModelParameters> + public sealed class NaiveBayesTrainer : TrainerEstimatorBase, MulticlassNaiveBayesModelParameters> { internal const string LoadName = "MultiClassNaiveBayes"; internal const string UserName = "Multiclass Naive Bayes"; @@ -39,7 +39,7 @@ internal sealed class Options : TrainerInputBaseWithLabel } /// Return the type of prediction task. - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; private static readonly TrainerInfo _info = new TrainerInfo(normalization: false, caching: false); @@ -90,10 +90,10 @@ private protected override SchemaShape.Column[] GetOutputColumnsCore(SchemaShape }; } - private protected override MulticlassPredictionTransformer MakeTransformer(MultiClassNaiveBayesModelParameters model, DataViewSchema trainSchema) - => new MulticlassPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name, LabelColumn.Name); + private protected override MulticlassPredictionTransformer MakeTransformer(MulticlassNaiveBayesModelParameters model, DataViewSchema trainSchema) + => new MulticlassPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name, LabelColumn.Name); - private protected override MultiClassNaiveBayesModelParameters TrainModelCore(TrainContext context) + private protected override MulticlassNaiveBayesModelParameters TrainModelCore(TrainContext context) { Host.CheckValue(context, nameof(context)); var data = context.TrainingSet; @@ -113,7 +113,7 @@ private protected override MultiClassNaiveBayesModelParameters TrainModelCore(Tr int[][] featureHistogram = new int[labelCount][]; using (var pch = Host.StartProgressChannel("Multi Class Naive Bayes training")) using (var ch = Host.Start("Training")) - using (var cursor = new MultiClassLabelCursor(labelCount, data, CursOpt.Features | CursOpt.Label)) + using (var cursor = new MulticlassLabelCursor(labelCount, data, CursOpt.Features | CursOpt.Label)) { int examplesProcessed = 0; pch.SetHeader(new ProgressHeader(new[] { "Examples Processed" }, new[] { "count" }), e => @@ -161,14 +161,14 @@ private protected override MultiClassNaiveBayesModelParameters TrainModelCore(Tr Array.Resize(ref labelHistogram, labelCount); Array.Resize(ref featureHistogram, labelCount); - return new MultiClassNaiveBayesModelParameters(Host, labelHistogram, featureHistogram, featureCount); + return new MulticlassNaiveBayesModelParameters(Host, labelHistogram, featureHistogram, featureCount); } [TlcModule.EntryPoint(Name = "Trainers.NaiveBayesClassifier", - Desc = "Train a MultiClassNaiveBayesTrainer.", + Desc = "Train a MulticlassNaiveBayesTrainer.", UserName = UserName, ShortName = ShortName)] - internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClassNaiveBayesTrainer(IHostEnvironment env, Options input) + internal static CommonOutputs.MulticlassClassificationOutput TrainMulticlassNaiveBayesTrainer(IHostEnvironment env, Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainMultiClassNaiveBayes"); @@ -181,7 +181,7 @@ internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClassNaiv } } - public sealed class MultiClassNaiveBayesModelParameters : + public sealed class MulticlassNaiveBayesModelParameters : ModelParametersBase>, IValueMapper { @@ -194,7 +194,7 @@ private static VersionInfo GetVersionInfo() verReadableCur: 0x00010001, verWeCanReadBack: 0x00010001, loaderSignature: LoaderSignature, - loaderAssemblyName: typeof(MultiClassNaiveBayesModelParameters).Assembly.FullName); + loaderAssemblyName: typeof(MulticlassNaiveBayesModelParameters).Assembly.FullName); } private readonly int[] _labelHistogram; @@ -207,7 +207,7 @@ private static VersionInfo GetVersionInfo() private readonly VectorType _outputType; /// Return the type of prediction task. - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; DataViewType IValueMapper.InputType => _inputType; @@ -230,7 +230,7 @@ private static VersionInfo GetVersionInfo() /// The histogram of labels. /// The feature histogram. /// The number of features. - internal MultiClassNaiveBayesModelParameters(IHostEnvironment env, int[] labelHistogram, int[][] featureHistogram, int featureCount) + internal MulticlassNaiveBayesModelParameters(IHostEnvironment env, int[] labelHistogram, int[][] featureHistogram, int featureCount) : base(env, LoaderSignature) { Host.AssertValue(labelHistogram); @@ -247,7 +247,7 @@ internal MultiClassNaiveBayesModelParameters(IHostEnvironment env, int[] labelHi _outputType = new VectorType(NumberDataViewType.Single, _labelCount); } - private MultiClassNaiveBayesModelParameters(IHostEnvironment env, ModelLoadContext ctx) + private MulticlassNaiveBayesModelParameters(IHostEnvironment env, ModelLoadContext ctx) : base(env, LoaderSignature, ctx) { // *** Binary format *** @@ -281,12 +281,12 @@ private MultiClassNaiveBayesModelParameters(IHostEnvironment env, ModelLoadConte _outputType = new VectorType(NumberDataViewType.Single, _labelCount); } - private static MultiClassNaiveBayesModelParameters Create(IHostEnvironment env, ModelLoadContext ctx) + private static MulticlassNaiveBayesModelParameters Create(IHostEnvironment env, ModelLoadContext ctx) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(ctx, nameof(ctx)); ctx.CheckAtModel(GetVersionInfo()); - return new MultiClassNaiveBayesModelParameters(env, ctx); + return new MulticlassNaiveBayesModelParameters(env, ctx); } private protected override void SaveCore(ModelSaveContext ctx) diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/OneVersusAllTrainer.cs similarity index 99% rename from src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs rename to src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/OneVersusAllTrainer.cs index 02bf659892..74d11ab7e7 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/OneVersusAllTrainer.cs @@ -23,7 +23,7 @@ using Newtonsoft.Json.Linq; [assembly: LoadableClass(OneVersusAllTrainer.Summary, typeof(OneVersusAllTrainer), typeof(OneVersusAllTrainer.Options), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer) }, OneVersusAllTrainer.UserNameValue, OneVersusAllTrainer.LoadNameValue, DocName = "trainer/OvaPkpd.md")] @@ -168,7 +168,7 @@ public override MulticlassPredictionTransformer Fit roles[0] = new KeyValuePair(new CR(DefaultColumnNames.Label), LabelColumn.Name); var td = new RoleMappedData(input, roles); - td.CheckMultiClassLabel(out var numClasses); + td.CheckMulticlassLabel(out var numClasses); var predictors = new TScalarPredictor[numClasses]; string featureColumn = null; @@ -229,7 +229,7 @@ private static VersionInfo GetVersionInfo() /// /// The type of the prediction task. /// - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; /// /// Function applied to output of predictors. Assume that we have n predictors (one per class) and for the i-th predictor, diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/PairwiseCouplingTrainer.cs similarity index 99% rename from src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs rename to src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/PairwiseCouplingTrainer.cs index 26ea2b463c..0f2d2046b6 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/PairwiseCouplingTrainer.cs @@ -15,7 +15,7 @@ using Microsoft.ML.Trainers; [assembly: LoadableClass(PairwiseCouplingTrainer.Summary, typeof(PairwiseCouplingTrainer), typeof(PairwiseCouplingTrainer.Options), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer) }, PairwiseCouplingTrainer.UserNameValue, PairwiseCouplingTrainer.LoadNameValue, DocName = "trainer/OvaPkpd.md")] [assembly: LoadableClass(typeof(PairwiseCouplingModelParameters), null, typeof(SignatureLoadModel), @@ -170,7 +170,7 @@ public override TTransformer Fit(IDataView input) roles[0] = new KeyValuePair(new CR(DefaultColumnNames.Label), LabelColumn.Name); var td = new RoleMappedData(input, roles); - td.CheckMultiClassLabel(out var numClasses); + td.CheckMulticlassLabel(out var numClasses); // Train M * (M+1) / 2 models arranged as a lower triangular matrix. var predictors = new TDistPredictor[numClasses][]; @@ -232,7 +232,7 @@ private static VersionInfo GetVersionInfo() private readonly IValueMapperDist[] _mappers; /// Return the type of prediction task. - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; private readonly VectorType _inputType; private readonly DataViewType _outputType; DataViewType IValueMapper.InputType => _inputType; diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/doc.xml b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/doc.xml similarity index 96% rename from src/Microsoft.ML.StandardTrainers/Standard/MultiClass/doc.xml rename to src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/doc.xml index 6cb6e2a24a..106a30baff 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/doc.xml +++ b/src/Microsoft.ML.StandardTrainers/Standard/MulticlassClassification/doc.xml @@ -2,7 +2,7 @@ - + Trains a multiclass Naive Bayes predictor that supports binary feature values. @@ -15,7 +15,7 @@ Specifically a feature value greater than zero is treated as true. - + pipeline.Add(new NaiveBayesClassifier diff --git a/src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs b/src/Microsoft.ML.StandardTrainers/Standard/SdcaMulticlass.cs similarity index 99% rename from src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs rename to src/Microsoft.ML.StandardTrainers/Standard/SdcaMulticlass.cs index 5a2a36c944..ccb265e44f 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/SdcaMulticlass.cs @@ -18,7 +18,7 @@ using Microsoft.ML.Trainers; [assembly: LoadableClass(SdcaMulticlassClassificationTrainer.Summary, typeof(SdcaMulticlassClassificationTrainer), typeof(SdcaMulticlassClassificationTrainer.Options), - new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, + new[] { typeof(SignatureMulticlassClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, SdcaMulticlassClassificationTrainer.UserNameValue, SdcaMulticlassClassificationTrainer.LoadNameValue, SdcaMulticlassClassificationTrainer.ShortName)] @@ -61,7 +61,7 @@ public sealed class Options : OptionsBase private readonly ISupportSdcaClassificationLoss _loss; - private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; + private protected override PredictionKind PredictionKind => PredictionKind.MulticlassClassification; /// /// Initializes a new instance of @@ -425,7 +425,7 @@ private protected override MulticlassLogisticRegressionModelParameters CreatePre private protected override void CheckLabel(RoleMappedData examples, out int weightSetCount) { - examples.CheckMultiClassLabel(out weightSetCount); + examples.CheckMulticlassLabel(out weightSetCount); } private protected override float[] InitializeFeatureNormSquared(int length) @@ -452,7 +452,7 @@ internal static partial class Sdca Desc = SdcaMulticlassClassificationTrainer.Summary, UserName = SdcaMulticlassClassificationTrainer.UserNameValue, ShortName = SdcaMulticlassClassificationTrainer.ShortName)] - public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, SdcaMulticlassClassificationTrainer.Options input) + public static CommonOutputs.MulticlassClassificationOutput TrainMulticlass(IHostEnvironment env, SdcaMulticlassClassificationTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainSDCA"); diff --git a/src/Microsoft.ML.StaticPipe/EvaluatorStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/EvaluatorStaticExtensions.cs index 61eb4bd924..b46c41289f 100644 --- a/src/Microsoft.ML.StaticPipe/EvaluatorStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/EvaluatorStaticExtensions.cs @@ -127,11 +127,11 @@ public static ClusteringMetrics Evaluate( /// The index delegate for the label column. /// The index delegate for columns from the prediction of a multiclass classifier. /// Under typical scenarios, this will just be the same tuple of results returned from the trainer. - /// If given a positive value, the will be filled with + /// If given a positive value, the will be filled with /// the top-K accuracy, that is, the accuracy assuming we consider an example with the correct class within /// the top-K values as being stored "correctly." /// The evaluation metrics. - public static MultiClassClassifierMetrics Evaluate( + public static MulticlassClassificationMetrics Evaluate( this MulticlassClassificationCatalog catalog, DataView data, Func> label, @@ -153,11 +153,11 @@ public static MultiClassClassifierMetrics Evaluate( string scoreName = indexer.Get(scoreCol); string predName = indexer.Get(predCol); - var args = new MultiClassClassifierEvaluator.Arguments() { }; + var args = new MulticlassClassificationEvaluator.Arguments() { }; if (topK > 0) args.OutputTopKAcc = topK; - var eval = new MultiClassClassifierEvaluator(env, args); + var eval = new MulticlassClassificationEvaluator(env, args); return eval.Evaluate(data.AsDynamic, labelName, scoreName, predName); } diff --git a/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs b/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs index 9dee1abcd2..ad2f3aeb16 100644 --- a/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs +++ b/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs @@ -227,7 +227,7 @@ public static class LbfgsMulticlassExtensions /// result in any way; it is only a way for the caller to be informed about what was learnt. /// The set of output columns including in order the predicted per-class likelihoods (between 0 and 1, and summing up to 1), and the predicted label. public static (Vector score, Key predictedLabel) - MultiClassLogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + MulticlassLogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, Key label, Vector features, Scalar weights = null, @@ -240,7 +240,7 @@ public static (Vector score, Key predictedLabel) { LbfgsStaticUtils.ValidateParams(label, features, weights, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity, onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { var trainer = new LogisticRegressionMulticlassClassificationTrainer(env, labelName, featuresName, weightsName, @@ -269,7 +269,7 @@ public static (Vector score, Key predictedLabel) /// result in any way; it is only a way for the caller to be informed about what was learnt. /// The set of output columns including in order the predicted per-class likelihoods (between 0 and 1, and summing up to 1), and the predicted label. public static (Vector score, Key predictedLabel) - MultiClassLogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + MulticlassLogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, Key label, Vector features, Scalar weights, @@ -281,7 +281,7 @@ public static (Vector score, Key predictedLabel) Contracts.CheckValue(options, nameof(options)); Contracts.CheckValueOrNull(onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { options.LabelColumnName = labelName; diff --git a/src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs b/src/Microsoft.ML.StaticPipe/MulticlassNaiveBayesStatic.cs similarity index 87% rename from src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs rename to src/Microsoft.ML.StaticPipe/MulticlassNaiveBayesStatic.cs index f01124156e..ff921f36bb 100644 --- a/src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs +++ b/src/Microsoft.ML.StaticPipe/MulticlassNaiveBayesStatic.cs @@ -9,12 +9,12 @@ namespace Microsoft.ML.StaticPipe { /// - /// MultiClass Classification trainer estimators. + /// Multiclass Classification trainer estimators. /// - public static partial class MultiClassClassificationStaticExtensions + public static partial class MulticlassClassificationStaticExtensions { /// - /// Predict a target using a linear multiclass classification model trained with the trainer. + /// Predict a target using a linear multiclass classification model trained with the trainer. /// /// The multiclass classification catalog trainer object. /// The label, or dependent variable. @@ -26,16 +26,16 @@ public static partial class MultiClassClassificationStaticExtensions /// result in any way; it is only a way for the caller to be informed about what was learnt. /// The set of output columns including in order the predicted per-class likelihoods (between 0 and 1, and summing up to 1), and the predicted label. public static (Vector score, Key predictedLabel) - MultiClassNaiveBayesTrainer(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + MulticlassNaiveBayesTrainer(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, Key label, Vector features, - Action onFit = null) + Action onFit = null) { Contracts.CheckValue(features, nameof(features)); Contracts.CheckValue(label, nameof(label)); Contracts.CheckValueOrNull(onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { var trainer = new NaiveBayesTrainer(env, labelName, featuresName); diff --git a/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs index af35f93554..fdab1d19e0 100644 --- a/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs @@ -365,7 +365,7 @@ public static (Vector score, Key predictedLabel) Sdca( Contracts.CheckParam(!(numberOfIterations < 1), nameof(numberOfIterations), "Must be positive if specified"); Contracts.CheckValueOrNull(onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { var trainer = new SdcaMulticlassClassificationTrainer(env, labelName, featuresName, weightsName, loss, l2Regularization, l1Threshold, numberOfIterations); @@ -405,7 +405,7 @@ public static (Vector score, Key predictedLabel) Sdca( Contracts.CheckValueOrNull(options); Contracts.CheckValueOrNull(onFit); - var rec = new TrainerEstimatorReconciler.MulticlassClassifier( + var rec = new TrainerEstimatorReconciler.MulticlassClassificationReconciler( (env, labelName, featuresName, weightsName) => { options.LabelColumnName = labelName; diff --git a/src/Microsoft.ML.StaticPipe/TrainerEstimatorReconciler.cs b/src/Microsoft.ML.StaticPipe/TrainerEstimatorReconciler.cs index fd0070ddcd..c2e55da928 100644 --- a/src/Microsoft.ML.StaticPipe/TrainerEstimatorReconciler.cs +++ b/src/Microsoft.ML.StaticPipe/TrainerEstimatorReconciler.cs @@ -396,9 +396,9 @@ public ImplLabel(Clustering rec) : base(rec, rec.Inputs) { } } /// - /// A reconciler for regression capable of handling the most common cases for regression. + /// A reconciler for multiclass classification capable of handling the most common cases for multiclass classification. /// - public sealed class MulticlassClassifier : TrainerEstimatorReconciler + public sealed class MulticlassClassificationReconciler : TrainerEstimatorReconciler { /// /// The delegate to create the multiclass classifier trainer instance. @@ -430,7 +430,7 @@ public sealed class MulticlassClassifier : TrainerEstimatorReconciler /// The input label column. /// The input features column. /// The input weights column, or null if there are no weights. - public MulticlassClassifier(EstimatorFactory estimatorFactory, Key label, Vector features, Scalar weights) + public MulticlassClassificationReconciler(EstimatorFactory estimatorFactory, Key label, Vector features, Scalar weights) : base(MakeInputs(Contracts.CheckRef(label, nameof(label)), Contracts.CheckRef(features, nameof(features)), weights), _fixedOutputNames) { @@ -452,12 +452,12 @@ protected override IEstimator ReconcileCore(IHostEnvironment env, private sealed class ImplLabel : Key { - public ImplLabel(MulticlassClassifier rec) : base(rec, rec.Inputs) { } + public ImplLabel(MulticlassClassificationReconciler rec) : base(rec, rec.Inputs) { } } private sealed class ImplScore : Vector { - public ImplScore(MulticlassClassifier rec) : base(rec, rec.Inputs) { } + public ImplScore(MulticlassClassificationReconciler rec) : base(rec, rec.Inputs) { } } } diff --git a/src/Microsoft.ML.StaticPipe/TrainingStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/TrainingStaticExtensions.cs index 3912195181..db6eb42d78 100644 --- a/src/Microsoft.ML.StaticPipe/TrainingStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/TrainingStaticExtensions.cs @@ -130,7 +130,7 @@ public static (RegressionMetrics metrics, Transformer is not provided, the random numbers generated to create it, will use this seed as value. /// And if it is not provided, the default value will be used. /// Per-fold results: metrics, models, scored datasets. - public static (MultiClassClassifierMetrics metrics, Transformer model, DataView scoredTestData)[] CrossValidate( + public static (MulticlassClassificationMetrics metrics, Transformer model, DataView scoredTestData)[] CrossValidate( this MulticlassClassificationCatalog catalog, DataView data, Estimator estimator, diff --git a/src/Microsoft.ML.Transforms/MetricStatistics.cs b/src/Microsoft.ML.Transforms/MetricStatistics.cs index 35a5f64937..a54483ec1d 100644 --- a/src/Microsoft.ML.Transforms/MetricStatistics.cs +++ b/src/Microsoft.ML.Transforms/MetricStatistics.cs @@ -211,42 +211,42 @@ void IMetricsStatistics.Add(BinaryClassificationMet } /// - /// The class holds summary - /// statistics over multiple observations of . + /// The class holds summary + /// statistics over multiple observations of . /// - public sealed class MultiClassClassifierMetricsStatistics : IMetricsStatistics + public sealed class MulticlassClassificationMetricsStatistics : IMetricsStatistics { /// - /// Summary statistics for . + /// Summary statistics for . /// public MetricStatistics MacroAccuracy { get; } /// - /// Summary statistics for . + /// Summary statistics for . /// public MetricStatistics MicroAccuracy { get; } /// - /// Summary statistics for . + /// Summary statistics for . /// public MetricStatistics LogLoss { get; } /// - /// Summary statistics for . + /// Summary statistics for . /// public MetricStatistics LogLossReduction { get; } /// - /// Summary statistics for . + /// Summary statistics for . /// public MetricStatistics TopKAccuracy { get; } /// - /// Summary statistics for . + /// Summary statistics for . /// public IReadOnlyList PerClassLogLoss { get; private set; } - internal MultiClassClassifierMetricsStatistics() + internal MulticlassClassificationMetricsStatistics() { MacroAccuracy = new MetricStatistics(); MicroAccuracy = new MetricStatistics(); @@ -259,7 +259,7 @@ internal MultiClassClassifierMetricsStatistics() /// Add a set of evaluation metrics to the set of observations. /// /// The observed binary classification evaluation metric - void IMetricsStatistics.Add(MultiClassClassifierMetrics metrics) + void IMetricsStatistics.Add(MulticlassClassificationMetrics metrics) { MacroAccuracy.Add(metrics.MacroAccuracy); MicroAccuracy.Add(metrics.MicroAccuracy); diff --git a/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs b/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs index 332e0e821e..8e4490658b 100644 --- a/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs +++ b/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs @@ -195,7 +195,7 @@ private static BinaryClassificationMetrics BinaryClassifierDelta( /// /// /// In this implementation, PFI computes the change in all possible multiclass classification evaluation metrics for each feature, and an - /// ImmutableArray of MultiClassClassifierMetrics objects is returned. See the sample below for an + /// ImmutableArray of MulticlassClassificationMetrics objects is returned. See the sample below for an /// example of working with these results to analyze the feature importance of a model. /// /// @@ -208,7 +208,7 @@ private static BinaryClassificationMetrics BinaryClassifierDelta( /// Limit the number of examples to evaluate on. null means examples (up to ~ 2 bln) from input will be used. /// The number of permutations to perform. /// Array of per-feature 'contributions' to the score. - public static ImmutableArray + public static ImmutableArray PermutationFeatureImportance( this MulticlassClassificationCatalog catalog, IPredictionTransformer model, @@ -219,11 +219,11 @@ public static ImmutableArray int? topExamples = null, int permutationCount = 1) { - return PermutationFeatureImportance.GetImportanceMetricsMatrix( + return PermutationFeatureImportance.GetImportanceMetricsMatrix( catalog.GetEnvironment(), model, data, - () => new MultiClassClassifierMetricsStatistics(), + () => new MulticlassClassificationMetricsStatistics(), idv => catalog.Evaluate(idv, label), MulticlassClassificationDelta, features, @@ -232,15 +232,15 @@ public static ImmutableArray topExamples); } - private static MultiClassClassifierMetrics MulticlassClassificationDelta( - MultiClassClassifierMetrics a, MultiClassClassifierMetrics b) + private static MulticlassClassificationMetrics MulticlassClassificationDelta( + MulticlassClassificationMetrics a, MulticlassClassificationMetrics b) { if (a.TopK != b.TopK) Contracts.Assert(a.TopK == b.TopK, "TopK to compare must be the same length."); var perClassLogLoss = ComputeSequenceDeltas(a.PerClassLogLoss, b.PerClassLogLoss); - return new MultiClassClassifierMetrics( + return new MulticlassClassificationMetrics( accuracyMicro: a.MicroAccuracy - b.MicroAccuracy, accuracyMacro: a.MacroAccuracy - b.MacroAccuracy, logLoss: a.LogLoss - b.LogLoss, diff --git a/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv b/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv index 302f08c27d..f740e6e0e3 100644 --- a/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv +++ b/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv @@ -8,7 +8,7 @@ Models.AnomalyPipelineEnsemble Combine anomaly detection models into an ensemble Models.BinaryClassificationEvaluator Evaluates a binary classification scored dataset. Microsoft.ML.Data.Evaluate Binary Microsoft.ML.Data.BinaryClassifierMamlEvaluator+Arguments Microsoft.ML.EntryPoints.CommonOutputs+ClassificationEvaluateOutput Models.BinaryEnsemble Combine binary classifiers into an ensemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator CreateBinaryEnsemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator+ClassifierInput Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Models.BinaryPipelineEnsemble Combine binary classification models into an ensemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator CreateBinaryPipelineEnsemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator+PipelineClassifierInput Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -Models.ClassificationEvaluator Evaluates a multi class classification scored dataset. Microsoft.ML.Data.Evaluate MultiClass Microsoft.ML.Data.MultiClassMamlEvaluator+Arguments Microsoft.ML.EntryPoints.CommonOutputs+ClassificationEvaluateOutput +Models.ClassificationEvaluator Evaluates a multi class classification scored dataset. Microsoft.ML.Data.Evaluate Multiclass Microsoft.ML.Data.MulticlassClassificationMamlEvaluator+Arguments Microsoft.ML.EntryPoints.CommonOutputs+ClassificationEvaluateOutput Models.ClusterEvaluator Evaluates a clustering scored dataset. Microsoft.ML.Data.Evaluate Clustering Microsoft.ML.Data.ClusteringMamlEvaluator+Arguments Microsoft.ML.EntryPoints.CommonOutputs+CommonEvaluateOutput Models.CrossValidationResultsCombiner Combine the metric data views returned from cross validation. Microsoft.ML.EntryPoints.CrossValidationMacro CombineMetrics Microsoft.ML.EntryPoints.CrossValidationMacro+CombineMetricsInput Microsoft.ML.EntryPoints.CrossValidationMacro+CombinedOutput Models.CrossValidator Cross validation for general learning Microsoft.ML.EntryPoints.CrossValidationMacro CrossValidate Microsoft.ML.EntryPoints.CrossValidationMacro+Arguments Microsoft.ML.EntryPoints.CommonOutputs+MacroOutput`1[Microsoft.ML.EntryPoints.CrossValidationMacro+Output] @@ -16,7 +16,7 @@ Models.CrossValidatorDatasetSplitter Split the dataset into the specified number Models.DatasetTransformer Applies a TransformModel to a dataset. Microsoft.ML.EntryPoints.ModelOperations Apply Microsoft.ML.EntryPoints.ModelOperations+ApplyTransformModelInput Microsoft.ML.EntryPoints.ModelOperations+ApplyTransformModelOutput Models.EnsembleSummary Summarize a pipeline ensemble predictor. Microsoft.ML.Trainers.Ensemble.PipelineEnsemble Summarize Microsoft.ML.EntryPoints.SummarizePredictor+Input Microsoft.ML.Trainers.Ensemble.PipelineEnsemble+SummaryOutput Models.FixedPlattCalibrator Apply a Platt calibrator with a fixed slope and offset to an input model Microsoft.ML.Calibrators.Calibrate FixedPlatt Microsoft.ML.Calibrators.Calibrate+FixedPlattInput Microsoft.ML.EntryPoints.CommonOutputs+CalibratorOutput -Models.MultiClassPipelineEnsemble Combine multiclass classifiers into an ensemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator CreateMultiClassPipelineEnsemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator+PipelineClassifierInput Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +Models.MultiClassPipelineEnsemble Combine multiclass classifiers into an ensemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator CreateMulticlassPipelineEnsemble Microsoft.ML.Trainers.Ensemble.EnsembleCreator+PipelineClassifierInput Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput Models.MultiOutputRegressionEvaluator Evaluates a multi output regression scored dataset. Microsoft.ML.Data.Evaluate MultiOutputRegression Microsoft.ML.Data.MultiOutputRegressionMamlEvaluator+Arguments Microsoft.ML.EntryPoints.CommonOutputs+CommonEvaluateOutput Models.NaiveCalibrator Apply a Naive calibrator to an input model Microsoft.ML.Calibrators.Calibrate Naive Microsoft.ML.Calibrators.Calibrate+NoArgumentsInput Microsoft.ML.EntryPoints.CommonOutputs+CalibratorOutput Models.OneVersusAll One-vs-All macro (OVA) Microsoft.ML.EntryPoints.OneVersusAllMacro OneVersusAll Microsoft.ML.EntryPoints.OneVersusAllMacro+Arguments Microsoft.ML.EntryPoints.CommonOutputs+MacroOutput`1[Microsoft.ML.EntryPoints.OneVersusAllMacro+Output] @@ -41,7 +41,7 @@ TimeSeriesProcessingEntryPoints.SsaChangePointDetector This transform detects th TimeSeriesProcessingEntryPoints.SsaSpikeDetector This transform detects the spikes in a seasonal time-series using Singular Spectrum Analysis (SSA). Microsoft.ML.Transforms.TimeSeries.TimeSeriesProcessingEntryPoints SsaSpikeDetector Microsoft.ML.Transforms.TimeSeries.SsaSpikeDetector+Options Microsoft.ML.EntryPoints.CommonOutputs+TransformOutput Trainers.AveragedPerceptronBinaryClassifier Averaged Perceptron Binary Classifier. Microsoft.ML.Trainers.AveragedPerceptronTrainer TrainBinary Microsoft.ML.Trainers.AveragedPerceptronTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Trainers.EnsembleBinaryClassifier Train binary ensemble. Microsoft.ML.Trainers.Ensemble.Ensemble CreateBinaryEnsemble Microsoft.ML.Trainers.Ensemble.EnsembleTrainer+Arguments Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -Trainers.EnsembleClassification Train multiclass ensemble. Microsoft.ML.Trainers.Ensemble.Ensemble CreateMultiClassEnsemble Microsoft.ML.Trainers.Ensemble.MulticlassDataPartitionEnsembleTrainer+Arguments Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +Trainers.EnsembleClassification Train multiclass ensemble. Microsoft.ML.Trainers.Ensemble.Ensemble CreateMulticlassEnsemble Microsoft.ML.Trainers.Ensemble.MulticlassDataPartitionEnsembleTrainer+Arguments Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput Trainers.EnsembleRegression Train regression ensemble. Microsoft.ML.Trainers.Ensemble.Ensemble CreateRegressionEnsemble Microsoft.ML.Trainers.Ensemble.RegressionEnsembleTrainer+Arguments Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.FastForestBinaryClassifier Uses a random forest learner to perform binary classification. Microsoft.ML.Trainers.FastTree.FastForest TrainBinary Microsoft.ML.Trainers.FastTree.FastForestBinaryClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Trainers.FastForestRegressor Trains a random forest to fit target values using least-squares. Microsoft.ML.Trainers.FastTree.FastForest TrainRegression Microsoft.ML.Trainers.FastTree.FastForestRegressionTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput @@ -54,19 +54,19 @@ Trainers.GeneralizedAdditiveModelBinaryClassifier Trains a gradient boosted stum Trainers.GeneralizedAdditiveModelRegressor Trains a gradient boosted stump per feature, on all features simultaneously, to fit target values using least-squares. It mantains no interactions between features. Microsoft.ML.Trainers.FastTree.Gam TrainRegression Microsoft.ML.Trainers.FastTree.GamRegressionTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.KMeansPlusPlusClusterer K-means is a popular clustering algorithm. With K-means, the data is clustered into a specified number of clusters in order to minimize the within-cluster sum of squares. K-means++ improves upon K-means by using a better method for choosing the initial cluster centers. Microsoft.ML.Trainers.KMeansTrainer TrainKMeans Microsoft.ML.Trainers.KMeansTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+ClusteringOutput Trainers.LightGbmBinaryClassifier Train a LightGBM binary classification model. Microsoft.ML.Trainers.LightGbm.LightGbm TrainBinary Microsoft.ML.Trainers.LightGbm.Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -Trainers.LightGbmClassifier Train a LightGBM multi class model. Microsoft.ML.Trainers.LightGbm.LightGbm TrainMultiClass Microsoft.ML.Trainers.LightGbm.Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +Trainers.LightGbmClassifier Train a LightGBM multi class model. Microsoft.ML.Trainers.LightGbm.LightGbm TrainMulticlass Microsoft.ML.Trainers.LightGbm.Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput Trainers.LightGbmRanker Train a LightGBM ranking model. Microsoft.ML.Trainers.LightGbm.LightGbm TrainRanking Microsoft.ML.Trainers.LightGbm.Options Microsoft.ML.EntryPoints.CommonOutputs+RankingOutput Trainers.LightGbmRegressor LightGBM Regression Microsoft.ML.Trainers.LightGbm.LightGbm TrainRegression Microsoft.ML.Trainers.LightGbm.Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.LinearSvmBinaryClassifier Train a linear SVM. Microsoft.ML.Trainers.LinearSvmTrainer TrainLinearSvm Microsoft.ML.Trainers.LinearSvmTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Trainers.LogisticRegressionBinaryClassifier Logistic Regression is a method in statistics used to predict the probability of occurrence of an event and can be used as a classification algorithm. The algorithm predicts the probability of occurrence of an event by fitting data to a logistical function. Microsoft.ML.Trainers.LogisticRegressionBinaryClassificationTrainer TrainBinary Microsoft.ML.Trainers.LogisticRegressionBinaryClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -Trainers.LogisticRegressionClassifier Logistic Regression is a method in statistics used to predict the probability of occurrence of an event and can be used as a classification algorithm. The algorithm predicts the probability of occurrence of an event by fitting data to a logistical function. Microsoft.ML.Trainers.LogisticRegressionBinaryClassificationTrainer TrainMultiClass Microsoft.ML.Trainers.LogisticRegressionMulticlassClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput -Trainers.NaiveBayesClassifier Train a MultiClassNaiveBayesTrainer. Microsoft.ML.Trainers.NaiveBayesTrainer TrainMultiClassNaiveBayesTrainer Microsoft.ML.Trainers.NaiveBayesTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +Trainers.LogisticRegressionClassifier Logistic Regression is a method in statistics used to predict the probability of occurrence of an event and can be used as a classification algorithm. The algorithm predicts the probability of occurrence of an event by fitting data to a logistical function. Microsoft.ML.Trainers.LogisticRegressionBinaryClassificationTrainer TrainMulticlass Microsoft.ML.Trainers.LogisticRegressionMulticlassClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +Trainers.NaiveBayesClassifier Train a MulticlassNaiveBayesTrainer. Microsoft.ML.Trainers.NaiveBayesTrainer TrainMulticlassNaiveBayesTrainer Microsoft.ML.Trainers.NaiveBayesTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput Trainers.OnlineGradientDescentRegressor Train a Online gradient descent perceptron. Microsoft.ML.Trainers.OnlineGradientDescentTrainer TrainRegression Microsoft.ML.Trainers.OnlineGradientDescentTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.OrdinaryLeastSquaresRegressor Train an OLS regression model. Microsoft.ML.Trainers.OlsTrainer TrainRegression Microsoft.ML.Trainers.OlsTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.PcaAnomalyDetector Train an PCA Anomaly model. Microsoft.ML.Trainers.RandomizedPcaTrainer TrainPcaAnomaly Microsoft.ML.Trainers.RandomizedPcaTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+AnomalyDetectionOutput Trainers.PoissonRegressor Train an Poisson regression model. Microsoft.ML.Trainers.PoissonRegressionTrainer TrainRegression Microsoft.ML.Trainers.PoissonRegressionTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.StochasticDualCoordinateAscentBinaryClassifier Train an SDCA binary model. Microsoft.ML.Trainers.Sdca TrainBinary Microsoft.ML.Trainers.LegacySdcaBinaryTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -Trainers.StochasticDualCoordinateAscentClassifier The SDCA linear multi-class classification trainer. Microsoft.ML.Trainers.Sdca TrainMultiClass Microsoft.ML.Trainers.SdcaMulticlassClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +Trainers.StochasticDualCoordinateAscentClassifier The SDCA linear multi-class classification trainer. Microsoft.ML.Trainers.Sdca TrainMulticlass Microsoft.ML.Trainers.SdcaMulticlassClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput Trainers.StochasticDualCoordinateAscentRegressor The SDCA linear regression trainer. Microsoft.ML.Trainers.Sdca TrainRegression Microsoft.ML.Trainers.SdcaRegressionTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.StochasticGradientDescentBinaryClassifier Train an Hogwild SGD binary model. Microsoft.ML.Trainers.LegacySgdBinaryTrainer TrainBinary Microsoft.ML.Trainers.LegacySgdBinaryTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Trainers.SymSgdBinaryClassifier Train a symbolic SGD. Microsoft.ML.Trainers.SymbolicSgdTrainer TrainSymSgd Microsoft.ML.Trainers.SymbolicSgdTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput diff --git a/test/BaselineOutput/Common/EntryPoints/core_manifest.json b/test/BaselineOutput/Common/EntryPoints/core_manifest.json index 0afdd544a4..468f101d96 100644 --- a/test/BaselineOutput/Common/EntryPoints/core_manifest.json +++ b/test/BaselineOutput/Common/EntryPoints/core_manifest.json @@ -1311,7 +1311,7 @@ "Kind": "Enum", "Values": [ "SignatureBinaryClassifierTrainer", - "SignatureMultiClassClassifierTrainer", + "SignatureMulticlassClassificationTrainer", "SignatureRankerTrainer", "SignatureRegressorTrainer", "SignatureMultiOutputRegressorTrainer", @@ -1502,7 +1502,7 @@ "Kind": "Enum", "Values": [ "SignatureBinaryClassifierTrainer", - "SignatureMultiClassClassifierTrainer", + "SignatureMulticlassClassificationTrainer", "SignatureRankerTrainer", "SignatureRegressorTrainer", "SignatureMultiOutputRegressorTrainer", @@ -3177,7 +3177,7 @@ "Kind": "Enum", "Values": [ "SignatureBinaryClassifierTrainer", - "SignatureMultiClassClassifierTrainer", + "SignatureMulticlassClassificationTrainer", "SignatureRankerTrainer", "SignatureRegressorTrainer", "SignatureMultiOutputRegressorTrainer", @@ -13988,7 +13988,7 @@ }, { "Name": "Trainers.NaiveBayesClassifier", - "Desc": "Train a MultiClassNaiveBayesTrainer.", + "Desc": "Train a MulticlassNaiveBayesTrainer.", "FriendlyName": "Multiclass Naive Bayes", "ShortName": "MNB", "Inputs": [ diff --git a/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs b/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs index 8f20941e70..97aab29f94 100644 --- a/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs +++ b/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs @@ -38,13 +38,13 @@ public class StochasticDualCoordinateAscentClassifierBench : WithExtraMetrics private TransformerChain> _trainedModel; private PredictionEngine _predictionEngine; private IrisData[][] _batches; - private MultiClassClassifierMetrics _metrics; + private MulticlassClassificationMetrics _metrics; protected override IEnumerable GetMetrics() { if (_metrics != null) yield return new Metric( - nameof(MultiClassClassifierMetrics.MacroAccuracy), + nameof(MulticlassClassificationMetrics.MacroAccuracy), _metrics.MacroAccuracy.ToString("0.##", CultureInfo.InvariantCulture)); } @@ -139,7 +139,7 @@ public void SetupPredictBenchmarks() IDataView testData = loader.Load(_dataPath); IDataView scoredTestData = _trainedModel.Transform(testData); - var evaluator = new MultiClassClassifierEvaluator(mlContext, new MultiClassClassifierEvaluator.Arguments()); + var evaluator = new MulticlassClassificationEvaluator(mlContext, new MulticlassClassificationEvaluator.Arguments()); _metrics = evaluator.Evaluate(scoredTestData, DefaultColumnNames.Label, DefaultColumnNames.Score, DefaultColumnNames.PredictedLabel); _batches = new IrisData[_batchSizes.Length][]; diff --git a/test/Microsoft.ML.Benchmarks/Text/MultiClassClassification.cs b/test/Microsoft.ML.Benchmarks/Text/MultiClassClassification.cs index fedfbcedc5..113ccad2f4 100644 --- a/test/Microsoft.ML.Benchmarks/Text/MultiClassClassification.cs +++ b/test/Microsoft.ML.Benchmarks/Text/MultiClassClassification.cs @@ -14,7 +14,7 @@ namespace Microsoft.ML.Benchmarks { [Config(typeof(TrainConfig))] - public class MultiClassClassificationTrain + public class MulticlassClassificationTrain { private string _dataPath_Wiki; @@ -90,7 +90,7 @@ public void CV_Multiclass_WikiDetox_WordEmbeddings_SDCAMC() } } - public class MultiClassClassificationTest + public class MulticlassClassificationTest { private string _dataPath_Wiki; private string _modelPath_Wiki; @@ -103,7 +103,7 @@ public void SetupScoringSpeedTests() if (!File.Exists(_dataPath_Wiki)) throw new FileNotFoundException(string.Format(Errors.DatasetNotFound, _dataPath_Wiki)); - _modelPath_Wiki = Path.Combine(Path.GetDirectoryName(typeof(MultiClassClassificationTest).Assembly.Location), @"WikiModel.zip"); + _modelPath_Wiki = Path.Combine(Path.GetDirectoryName(typeof(MulticlassClassificationTest).Assembly.Location), @"WikiModel.zip"); string cmd = @"CV k=5 data=" + _dataPath_Wiki + " loader=TextLoader{quote=- sparse=- col=Label:R4:0 col=rev_id:TX:1 col=comment:TX:2 col=logged_in:BL:4 col=ns:TX:5 col=sample:TX:6 col=split:TX:7 col=year:R4:3 header=+} xf=Convert{col=logged_in type=R4}" + @@ -121,7 +121,7 @@ public void SetupScoringSpeedTests() public void Test_Multiclass_WikiDetox_BigramsAndTrichar_OVAAveragedPerceptron() { // This benchmark is profiling bulk scoring speed and not training speed. - string modelpath = Path.Combine(Path.GetDirectoryName(typeof(MultiClassClassificationTest).Assembly.Location), @"WikiModel.fold000.zip"); + string modelpath = Path.Combine(Path.GetDirectoryName(typeof(MulticlassClassificationTest).Assembly.Location), @"WikiModel.fold000.zip"); string cmd = @"Test data=" + _dataPath_Wiki + " in=" + modelpath; var environment = EnvironmentFactory.CreateClassificationEnvironment(); diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index 7dc92cb996..ea6ab6ed68 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -1191,7 +1191,7 @@ public void EntryPointMulticlassPipelineEnsemble() .ScoredData; } - var mcEnsembleModel = EnsembleCreator.CreateMultiClassPipelineEnsemble(Env, + var mcEnsembleModel = EnsembleCreator.CreateMulticlassPipelineEnsemble(Env, new EnsembleCreator.PipelineClassifierInput() { ModelCombiner = EnsembleCreator.ClassifierCombiner.Average, @@ -1771,7 +1771,7 @@ public void EntryPointEvaluateBinary() } [Fact] - public void EntryPointEvaluateMultiClass() + public void EntryPointEvaluateMulticlass() { var dataPath = GetDataPath("iris.txt"); var warningsPath = DeleteOutputPath("warnings.idv"); @@ -1898,7 +1898,7 @@ public void EntryPointLightGbmBinary() } [LightGBMFact] - public void EntryPointLightGbmMultiClass() + public void EntryPointLightGbmMulticlass() { Env.ComponentCatalog.RegisterAssembly(typeof(LightGbmBinaryModelParameters).Assembly); TestEntryPointRoutine(GetDataPath(@"iris.txt"), "Trainers.LightGbmClassifier"); @@ -1911,7 +1911,7 @@ public void EntryPointSdcaBinary() } [Fact] - public void EntryPointSDCAMultiClass() + public void EntryPointSDCAMulticlass() { TestEntryPointRoutine("iris.txt", "Trainers.StochasticDualCoordinateAscentClassifier"); } @@ -1923,7 +1923,7 @@ public void EntryPointSDCARegression() } [Fact] - public void EntryPointLogisticRegressionMultiClass() + public void EntryPointLogisticRegressionMulticlass() { TestEntryPointRoutine("iris.txt", "Trainers.LogisticRegressionClassifier"); } @@ -2040,7 +2040,7 @@ public void EntryPointRegressionEnsemble() } [Fact] - public void EntryPointNaiveBayesMultiClass() + public void EntryPointNaiveBayesMulticlass() { TestEntryPointRoutine("iris.txt", "Trainers.NaiveBayesClassifier"); } @@ -3365,7 +3365,7 @@ public void EntryPointLinearPredictorSummary() NumberOfThreads = 1, ShowTrainingStatistics = true }; - var mcModel = LogisticRegressionBinaryClassificationTrainer.TrainMultiClass(Env, mcLrInput).PredictorModel; + var mcModel = LogisticRegressionBinaryClassificationTrainer.TrainMulticlass(Env, mcLrInput).PredictorModel; var output = SummarizePredictor.Summarize(Env, new SummarizePredictor.Input() { PredictorModel = model }); @@ -4307,7 +4307,7 @@ public void TestCrossValidationMacro() } [Fact] - public void TestCrossValidationMacroWithMultiClass() + public void TestCrossValidationMacroWithMulticlass() { var dataPath = GetDataPath(@"Train-Tiny-28x28.txt"); string inputGraph = @" @@ -4394,7 +4394,7 @@ public void TestCrossValidationMacroWithMultiClass() }, 'StratificationColumn': null, 'NumFolds': 2, - 'Kind': 'SignatureMultiClassClassifierTrainer', + 'Kind': 'SignatureMulticlassClassificationTrainer', 'LabelColumn': 'Label', 'WeightColumn': null, 'GroupColumn': null, @@ -4506,7 +4506,7 @@ public void TestCrossValidationMacroWithMultiClass() } [Fact] - public void TestCrossValidationMacroMultiClassWithWarnings() + public void TestCrossValidationMacroMulticlassWithWarnings() { var dataPath = GetDataPath(@"Train-Tiny-28x28.txt"); string inputGraph = @" @@ -4621,7 +4621,7 @@ public void TestCrossValidationMacroMultiClassWithWarnings() }, 'StratificationColumn': 'Strat', 'NumFolds': 2, - 'Kind': 'SignatureMultiClassClassifierTrainer', + 'Kind': 'SignatureMulticlassClassificationTrainer', 'LabelColumn': 'Label', 'WeightColumn': null, 'GroupColumn': null, @@ -5346,7 +5346,7 @@ public void TestOvaMacro() var data = runner.GetOutput("overallMetrics"); var schema = data.Schema; - var accCol = schema.GetColumnOrNull(MultiClassClassifierEvaluator.AccuracyMacro); + var accCol = schema.GetColumnOrNull(MulticlassClassificationEvaluator.AccuracyMacro); Assert.True(accCol.HasValue); bool b; using (var cursor = data.GetRowCursor(accCol.Value)) @@ -5517,7 +5517,7 @@ public void TestOvaMacroWithUncalibratedLearner() var data = runner.GetOutput("overallMetrics"); var schema = data.Schema; - var accCol = schema.GetColumnOrNull(MultiClassClassifierEvaluator.AccuracyMacro); + var accCol = schema.GetColumnOrNull(MulticlassClassificationEvaluator.AccuracyMacro); Assert.True(accCol.HasValue); bool b; using (var cursor = data.GetRowCursor(accCol.Value)) diff --git a/test/Microsoft.ML.Functional.Tests/Common.cs b/test/Microsoft.ML.Functional.Tests/Common.cs index 5756893966..d135be3af4 100644 --- a/test/Microsoft.ML.Functional.Tests/Common.cs +++ b/test/Microsoft.ML.Functional.Tests/Common.cs @@ -210,10 +210,10 @@ public static void AssertMetrics(ClusteringMetrics metrics) } /// - /// Check that a object is valid. + /// Check that a object is valid. /// /// The metrics object. - public static void AssertMetrics(MultiClassClassifierMetrics metrics) + public static void AssertMetrics(MulticlassClassificationMetrics metrics) { Assert.InRange(metrics.MacroAccuracy, 0, 1); Assert.InRange(metrics.MicroAccuracy, 0, 1); diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/0.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/0.out.txt index dfb38e3ddf..397be516b8 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/0.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/0.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l1=0.1 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l1=0.1 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/1.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/1.out.txt index dff7910197..57b1e0efc6 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/1.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/1.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 ot=0.0001 m=5 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 ot=0.0001 m=5 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/10.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/10.out.txt index e790ae127b..58489c3fc1 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/10.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/10.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/11.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/11.out.txt index a19f6b71ea..bee0f5eddf 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/11.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/11.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0.1 l1=0 ot=0.0001 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0.1 l1=0 ot=0.0001 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/12.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/12.out.txt index 3e0853b9ab..39573d211a 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/12.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/12.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0 m=5 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0 m=5 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/13.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/13.out.txt index b27e170547..889b1c5527 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/13.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/13.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0.1 m=50 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0.1 m=50 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/14.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/14.out.txt index cec044579a..666df75da2 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/14.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/14.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l1=0.1 ot=0.0001 m=50 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l1=0.1 ot=0.0001 m=50 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/15.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/15.out.txt index db1392f451..825d8e1574 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/15.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/15.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0 ot=0.0001 m=5 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0 ot=0.0001 m=5 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/16.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/16.out.txt index 09d0b67f6a..71aa4172d5 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/16.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/16.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0.1 ot=0.0001} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0.1 ot=0.0001} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/17.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/17.out.txt index 69af484d0f..e39706c341 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/17.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/17.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{m=50 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{m=50 initwts=0.5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/18.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/18.out.txt index a2a6175d62..7216f5f553 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/18.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/18.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0.1 l1=0 m=50 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0.1 l1=0 m=50 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/19.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/19.out.txt index fc64864cbf..bc71b12387 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/19.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/19.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0 m=50 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0 m=50 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/2.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/2.out.txt index 869daa1da6..14031a6c6c 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/2.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/2.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0 initwts=0.1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/20.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/20.out.txt index 4989e66e46..d23d6071e6 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/20.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/20.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0.1 ot=0.0001 m=5 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0.1 ot=0.0001 m=5 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/3.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/3.out.txt index 149e02e0a5..5058cf5ad1 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/3.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/3.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0.1 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0.1 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/4.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/4.out.txt index ae0612f960..dd4e0c36e1 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/4.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/4.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0.1 l1=0.1 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0.1 l1=0.1 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/5.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/5.out.txt index 5beb122264..1671397241 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/5.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/5.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l1=0.1 ot=0.0001 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l1=0.1 ot=0.0001 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/6.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/6.out.txt index 092fa661cc..113d983fc5 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/6.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/6.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0 ot=0.0001 m=5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0 ot=0.0001 m=5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/7.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/7.out.txt index 6a40136ac1..e8c6fd3649 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/7.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/7.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{ot=0.0001 m=5 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{ot=0.0001 m=5 initwts=1} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/8.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/8.out.txt index 7ff1a776be..4ecb30f88c 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/8.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/8.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{m=5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{m=5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/9.out.txt b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/9.out.txt index 2844ceb9f2..8b623d683d 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/9.out.txt +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestData/MultiClassifier/9.out.txt @@ -1,4 +1,4 @@ -maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MultiClassLogisticRegression{l2=0 l1=0.1 m=5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt +maml.exe TrainTest test=F:\data\MNIST\Train-28x28.txt tr=MulticlassLogisticRegression{l2=0 l1=0.1 m=5} loader=TextLoader{col=Label:R4:0 col=Features:R4:1-784} data=F:\data\MNIST\Test-28x28.txt Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off. Beginning optimization num vars: 7850 diff --git a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestResultProcessor.cs b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestResultProcessor.cs index 904b446581..d01075e000 100644 --- a/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestResultProcessor.cs +++ b/test/Microsoft.ML.Predictor.Tests/ResultProcessor/TestResultProcessor.cs @@ -107,12 +107,12 @@ public void RPSingleClassifierTestWIthEmptyLines() /// [Fact(Skip = "Need CoreTLC specific baseline update")] [TestCategory("Results Processor")] - public void RPMultiClassifierTest() + public void RPMulticlassifierTest() { List testFiles = new List(); for (int i = 0; i < 21; i++) { - testFiles.Add("MultiClassifier." + i.ToString() + ".out.txt"); + testFiles.Add("Multiclassifier." + i.ToString() + ".out.txt"); } RunTestCore("RPMultiClassifierTest", diff --git a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs index 1035ffeb35..03a1feee8c 100644 --- a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs +++ b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs @@ -56,7 +56,7 @@ public IList GetDatasetsForBinaryClassifierBaseTest() }; } - public IList GetDatasetsForMulticlassClassifierTest() + public IList GetDatasetsForMulticlassClassificationTest() { return new[] { TestDatasets.breastCancer, @@ -174,7 +174,7 @@ public void MulticlassSdcaTest() { var predictors = new[] { TestLearners.multiclassSdca, TestLearners.multiclassSdcaL1, TestLearners.multiclassSdcaSmoothedHinge }; - var datasets = GetDatasetsForMulticlassClassifierTest(); + var datasets = GetDatasetsForMulticlassClassificationTest(); RunAllTests(predictors, datasets); Done(); } @@ -199,7 +199,7 @@ public void MulticlassTreeFeaturizedLRTest() [Fact(Skip = "Need CoreTLC specific baseline update")] [TestCategory("Multiclass")] [TestCategory("Evaluators")] - public void MultiClassCVTest() + public void MulticlassCVTest() { var predictor = new PredictorAndArgs { @@ -501,7 +501,7 @@ public void DartLightGBMTest() [LightGBMFact] [TestCategory("Multiclass")] [TestCategory("LightGBM")] - public void MultiClassifierLightGBMKeyLabelTest() + public void MulticlassifierLightGBMKeyLabelTest() { var multiPredictors = new[] { TestLearners.LightGBMMC }; var multiClassificationDatasets = new[] { TestDatasets.irisLoader }; @@ -515,7 +515,7 @@ public void MultiClassifierLightGBMKeyLabelTest() [LightGBMFact] [TestCategory("Multiclass")] [TestCategory("LightGBM")] - public void MultiClassifierLightGBMKeyLabelU404Test() + public void MulticlassifierLightGBMKeyLabelU404Test() { var multiPredictors = new[] { TestLearners.LightGBMMC }; var multiClassificationDatasets = new[] { TestDatasets.irisLoaderU404 }; @@ -762,14 +762,14 @@ public void TestEnsembleCombiner() } [X64Fact("x86 fails. Associated GitHubIssue: https://github.com/dotnet/machinelearning/issues/1216")] - public void TestMultiClassEnsembleCombiner() + public void TestMulticlassEnsembleCombiner() { var dataPath = GetDataPath("breast-cancer.txt"); var dataView = ML.Data.LoadFromTextFile(dataPath); var predictors = new PredictorModel[] { - LightGbm.TrainMultiClass(Env, new Options + LightGbm.TrainMulticlass(Env, new Options { FeatureColumnName = "Features", NumberOfIterations = 5, @@ -777,7 +777,7 @@ public void TestMultiClassEnsembleCombiner() LabelColumnName = DefaultColumnNames.Label, TrainingData = dataView }).PredictorModel, - LogisticRegressionBinaryClassificationTrainer.TrainMultiClass(Env, new LogisticRegressionMulticlassClassificationTrainer.Options() + LogisticRegressionBinaryClassificationTrainer.TrainMulticlass(Env, new LogisticRegressionMulticlassClassificationTrainer.Options() { FeatureColumnName = "Features", LabelColumnName = DefaultColumnNames.Label, @@ -785,7 +785,7 @@ public void TestMultiClassEnsembleCombiner() TrainingData = dataView, NormalizeFeatures = NormalizeOption.No }).PredictorModel, - LogisticRegressionBinaryClassificationTrainer.TrainMultiClass(Env, new LogisticRegressionMulticlassClassificationTrainer.Options() + LogisticRegressionBinaryClassificationTrainer.TrainMulticlass(Env, new LogisticRegressionMulticlassClassificationTrainer.Options() { FeatureColumnName = "Features", LabelColumnName = DefaultColumnNames.Label, @@ -794,7 +794,7 @@ public void TestMultiClassEnsembleCombiner() NormalizeFeatures = NormalizeOption.No }).PredictorModel }; - CombineAndTestEnsembles(dataView, "weightedensemblemulticlass", "oc=multiaverage", PredictionKind.MultiClassClassification, predictors); + CombineAndTestEnsembles(dataView, "weightedensemblemulticlass", "oc=multiaverage", PredictionKind.MulticlassClassification, predictors); } private void CombineAndTestEnsembles(IDataView idv, string name, string options, PredictionKind predictionKind, @@ -852,10 +852,10 @@ private void CombineAndTestEnsembles(IDataView idv, string name, string options, { using (var curs = scored.GetRowCursor(cols)) { - var scoreGetter = predictionKind == PredictionKind.MultiClassClassification ? + var scoreGetter = predictionKind == PredictionKind.MulticlassClassification ? (ref float dst) => dst = 0 : curs.GetGetter(scoreCol); - var vectorScoreGetter = predictionKind == PredictionKind.MultiClassClassification ? + var vectorScoreGetter = predictionKind == PredictionKind.MulticlassClassification ? curs.GetGetter>(scoreCol) : (ref VBuffer dst) => dst = default; var probGetter = predictionKind == PredictionKind.BinaryClassification ? @@ -871,10 +871,10 @@ private void CombineAndTestEnsembles(IDataView idv, string name, string options, var predGetters = new ValueGetter[predCount]; for (int i = 0; i < predCount; i++) { - scoreGetters[i] = predictionKind == PredictionKind.MultiClassClassification ? + scoreGetters[i] = predictionKind == PredictionKind.MulticlassClassification ? (ref float dst) => dst = 0 : cursors[i].GetGetter(scoreColArray[i].Value); - vectorScoreGetters[i] = predictionKind == PredictionKind.MultiClassClassification ? + vectorScoreGetters[i] = predictionKind == PredictionKind.MulticlassClassification ? cursors[i].GetGetter>(scoreColArray[i].Value) : (ref VBuffer dst) => dst = default; probGetters[i] = predictionKind == PredictionKind.BinaryClassification ? @@ -2016,9 +2016,9 @@ public void BinaryClassifierTrembleTest() [Fact(Skip = "Need CoreTLC specific baseline update")] [TestCategory("MultiClass")] [TestCategory("TrembleDecisionTree")] - public void MultiClassClassifierTrembleTest() + public void MulticlassClassificationTrembleTest() { - var multiClassPredictors = new[] { TestLearners.MultiClassTrembleDecisionTreeLR }; + var multiClassPredictors = new[] { TestLearners.MulticlassTrembleDecisionTreeLR }; var multiClassClassificationDatasets = new List(); multiClassClassificationDatasets.Add(TestDatasets.iris); multiClassClassificationDatasets.Add(TestDatasets.adultCatAsAtt); @@ -2067,10 +2067,10 @@ public void BinaryClassifierDecisionTreeWeightingTest() [Fact(Skip = "Need CoreTLC specific baseline update")] [TestCategory("MultiClass")] [TestCategory("TrembleDecisionTree"), Priority(2)] - public void MultiClassClassifierDecisionTreeTest() + public void MulticlassClassificationDecisionTreeTest() { - var multiClassPredictors = new[] { TestLearners.MultiClassDecisionTreeDefault, TestLearners.MultiClassDecisionTreeGini, - TestLearners.MultiClassDecisionTreePruning, TestLearners.MultiClassDecisionTreeModified }; + var multiClassPredictors = new[] { TestLearners.MulticlassDecisionTreeDefault, TestLearners.MulticlassDecisionTreeGini, + TestLearners.MulticlassDecisionTreePruning, TestLearners.MulticlassDecisionTreeModified }; var multiClassClassificationDatasets = new List(); multiClassClassificationDatasets.Add(TestDatasets.iris); multiClassClassificationDatasets.Add(TestDatasets.adultCatAsAtt); @@ -2086,10 +2086,10 @@ public void MultiClassClassifierDecisionTreeTest() [TestCategory("MultiClass")] [TestCategory("Weighting Predictors")] [TestCategory("TrembleDecisionTree"), Priority(2)] - public void MultiClassifierDecisionTreeWeightingTest() + public void MulticlassifierDecisionTreeWeightingTest() { - var multiClassPredictors = new[] { TestLearners.MultiClassDecisionTreeDefault, TestLearners.MultiClassDecisionTreeGini, - TestLearners.MultiClassDecisionTreePruning, TestLearners.MultiClassDecisionTreeModified }; + var multiClassPredictors = new[] { TestLearners.MulticlassDecisionTreeDefault, TestLearners.MulticlassDecisionTreeGini, + TestLearners.MulticlassDecisionTreePruning, TestLearners.MulticlassDecisionTreeModified }; var binaryClassificationDatasets = new List(GetDatasetsForClassificationWeightingPredictorsTest()); RunAllTests(multiClassPredictors, binaryClassificationDatasets); Done(); diff --git a/test/Microsoft.ML.StaticPipelineTesting/Training.cs b/test/Microsoft.ML.StaticPipelineTesting/Training.cs index 85639f3019..e5795dc30a 100644 --- a/test/Microsoft.ML.StaticPipelineTesting/Training.cs +++ b/test/Microsoft.ML.StaticPipelineTesting/Training.cs @@ -691,7 +691,7 @@ public void MulticlassLogisticRegression() // With a custom loss function we no longer get calibrated predictions. var est = reader.MakeNewEstimator() .Append(r => (label: r.label.ToKey(), r.features)) - .Append(r => (r.label, preds: catalog.Trainers.MultiClassLogisticRegression( + .Append(r => (r.label, preds: catalog.Trainers.MulticlassLogisticRegression( r.label, r.features, null, @@ -913,7 +913,7 @@ public void LightGBMRanking() } [LightGBMFact] - public void MultiClassLightGBM() + public void MulticlassLightGBM() { var env = new MLContext(seed: 0); var dataPath = GetDataPath(TestDatasets.iris.trainFilename); @@ -951,7 +951,7 @@ public void MultiClassLightGBM() } [Fact] - public void MultiClassNaiveBayesTrainer() + public void MulticlassNaiveBayesTrainer() { var env = new MLContext(seed: 0); var dataPath = GetDataPath(TestDatasets.iris.trainFilename); @@ -961,12 +961,12 @@ public void MultiClassNaiveBayesTrainer() var reader = TextLoaderStatic.CreateLoader(env, c => (label: c.LoadText(0), features: c.LoadFloat(1, 4))); - MultiClassNaiveBayesModelParameters pred = null; + MulticlassNaiveBayesModelParameters pred = null; // With a custom loss function we no longer get calibrated predictions. var est = reader.MakeNewEstimator() .Append(r => (label: r.label.ToKey(), r.features)) - .Append(r => (r.label, preds: catalog.Trainers.MultiClassNaiveBayesTrainer( + .Append(r => (r.label, preds: catalog.Trainers.MulticlassNaiveBayesTrainer( r.label, r.features, onFit: p => pred = p))); @@ -1189,7 +1189,7 @@ public void MatrixFactorization() } [LightGBMFact] - public void MultiClassLightGbmStaticPipelineWithInMemoryData() + public void MulticlassLightGbmStaticPipelineWithInMemoryData() { // Create a general context for ML.NET operations. It can be used for exception tracking and logging, // as a catalog of available operations and as the source of randomness. diff --git a/test/Microsoft.ML.TestFramework/Learners.cs b/test/Microsoft.ML.TestFramework/Learners.cs index 0d2015db01..7367583dfd 100644 --- a/test/Microsoft.ML.TestFramework/Learners.cs +++ b/test/Microsoft.ML.TestFramework/Learners.cs @@ -96,14 +96,14 @@ static TestLearnersBase() public static PredictorAndArgs multiclassSdcaL1 = new PredictorAndArgs { Trainer = new SubComponent("SDCAMC", "l2=1e-04 l1=0.5 maxIterations=20 checkFreq=0 nt=1"), - Tag = "MultiClassSDCA-L1" + Tag = "MulticlassSDCA-L1" }; // New. public static PredictorAndArgs multiclassSdcaSmoothedHinge = new PredictorAndArgs { Trainer = new SubComponent("SDCAMC", "l2=1e-04 loss=SmoothedHinge maxIterations=20 checkFreq=0 nt=1"), - Tag = "MultiClassSDCA-SmoothedHinge" + Tag = "MulticlassSDCA-SmoothedHinge" }; // Old. @@ -731,7 +731,7 @@ public static PredictorAndArgs DssmDefault(int qryFeaturesCount, int docFeatures }; public static string BinaryTrembleTrainer = "BinaryTremble"; - public static string MultiClassTrembleTrainer = "MultiClassTremble"; + public static string MulticlassTrembleTrainer = "MultiClassTremble"; public static PredictorAndArgs BinaryTrembleDecisionTreeLR = new PredictorAndArgs { @@ -769,34 +769,34 @@ public static PredictorAndArgs DssmDefault(int qryFeaturesCount, int docFeatures Tag = "BinaryDT-rewt" }; - public static PredictorAndArgs MultiClassTrembleDecisionTreeLR = new PredictorAndArgs + public static PredictorAndArgs MulticlassTrembleDecisionTreeLR = new PredictorAndArgs { - Trainer = new SubComponent(MultiClassTrembleTrainer, "inp=SingleFeaturePredictor inp=LogisticRegression{maxiter=10 quiet=+ t-} lnp=MultiClassLogisticRegression{maxiter=100 quiet=+ t-} nl=8"), - Tag = "MultiClassTremble-lr" + Trainer = new SubComponent(MulticlassTrembleTrainer, "inp=SingleFeaturePredictor inp=LogisticRegression{maxiter=10 quiet=+ t-} lnp=MulticlassLogisticRegression{maxiter=100 quiet=+ t-} nl=8"), + Tag = "MulticlassTremble-lr" }; - public static PredictorAndArgs MultiClassDecisionTreeDefault = new PredictorAndArgs + public static PredictorAndArgs MulticlassDecisionTreeDefault = new PredictorAndArgs { - Trainer = new SubComponent(MultiClassTrembleTrainer, "nl=20"), - Tag = "MultiClassDT-def" + Trainer = new SubComponent(MulticlassTrembleTrainer, "nl=20"), + Tag = "MulticlassDT-def" }; - public static PredictorAndArgs MultiClassDecisionTreePruning = new PredictorAndArgs + public static PredictorAndArgs MulticlassDecisionTreePruning = new PredictorAndArgs { - Trainer = new SubComponent(MultiClassTrembleTrainer, "nl=20 prune=+"), - Tag = "MultiClassDT-prune" + Trainer = new SubComponent(MulticlassTrembleTrainer, "nl=20 prune=+"), + Tag = "MulticlassDT-prune" }; - public static PredictorAndArgs MultiClassDecisionTreeGini = new PredictorAndArgs + public static PredictorAndArgs MulticlassDecisionTreeGini = new PredictorAndArgs { - Trainer = new SubComponent(MultiClassTrembleTrainer, "nl=20 imp=Gini"), - Tag = "MultiClassDT-gini" + Trainer = new SubComponent(MulticlassTrembleTrainer, "nl=20 imp=Gini"), + Tag = "MulticlassDT-gini" }; - public static PredictorAndArgs MultiClassDecisionTreeModified = new PredictorAndArgs + public static PredictorAndArgs MulticlassDecisionTreeModified = new PredictorAndArgs { - Trainer = new SubComponent(MultiClassTrembleTrainer, "mil=2 inp=SingleFeaturePredictor{nb=FIFTEEN ff=0.7} nl=40"), - Tag = "MultiClassDT-mod" + Trainer = new SubComponent(MulticlassTrembleTrainer, "mil=2 inp=SingleFeaturePredictor{nb=FIFTEEN ff=0.7} nl=40"), + Tag = "MulticlassDT-mod" }; public const string BinaryBPMTrainer = "BinaryBPM"; diff --git a/test/Microsoft.ML.TestFramework/TestCommandBase.cs b/test/Microsoft.ML.TestFramework/TestCommandBase.cs index 24ee937489..edea04349f 100644 --- a/test/Microsoft.ML.TestFramework/TestCommandBase.cs +++ b/test/Microsoft.ML.TestFramework/TestCommandBase.cs @@ -818,7 +818,7 @@ public void CommandSavePredictor() [TestCategory(Cat)] [Fact(Skip = "Need CoreTLC specific baseline update")] - public void SaveMultiClassLrPredictorAsSummary() + public void SaveMulticlassLrPredictorAsSummary() { // First run a training. string pathData = GetDataPath("iris.txt"); @@ -918,7 +918,7 @@ public void CommandCrossValidationAndSave() string extraArgs = string.Format("{0} {1} {2} {3} k={4}", "prexf=Term{col=Label:Cat} prexf=CategoricalTransform{col=Cat01}", "xf=TextTransform{col=Text} xf=Concat{col=Features:Cat01,Text}", - "threads- tr=MultiClassLogisticRegression{numThreads=1}", "norm=No", numFolds); + "threads- tr=MulticlassLogisticRegression{numThreads=1}", "norm=No", numFolds); const string loaderArgs = "loader=TextLoader{col=Label:R4:0 col=Cat:TX:1 col=Cat01:TX:2 col=Text:TX:3 header=+}"; TestCore("cv", pathData, loaderArgs, extraArgs); @@ -1166,7 +1166,7 @@ public void CommandTrainMlrWithLabelNames() const string loaderCmdline = @"loader=TextLoader{col=Label:TX:0 col=Features:R4:1-4 header=+}"; string pathTrain = GetDataPath("iris-label-name.txt"); OutputPath trainModel = ModelPath(); - const string trainArgs = "tr=MultiClassLogisticRegression{maxiter=100 t=-} xf=Term{col=Label} seed=1"; + const string trainArgs = "tr=MulticlassLogisticRegression{maxiter=100 t=-} xf=Term{col=Label} seed=1"; TestCore("train", pathTrain, loaderCmdline, trainArgs); _step++; @@ -1448,13 +1448,13 @@ public void CommandTrainScoreEvaluate() [TestCategory(Cat), TestCategory("Multiclass")] [Fact(Skip = "Need CoreTLC specific baseline update")] - public void CommandTrainScoreEvaluateMultiClass() + public void CommandTrainScoreEvaluateMulticlass() { // First run a training. string pathData = GetDataPath("iris-label-name.txt"); OutputPath trainModel = ModelPath(); TestCore("train", pathData, "loader=TextLoader{header+ col=Label:TX:0 col=Features:1-4} xf=Term{col=Label}", - "lab=Label feat=Features seed=42 tr=MultiClassNeuralNetwork{output=3 accel=sse lr=0.1 iter=70} norm=Warn"); + "lab=Label feat=Features seed=42 tr=MulticlassNeuralNetwork{output=3 accel=sse lr=0.1 iter=70} norm=Warn"); // Then, run the score. _step++; @@ -1478,7 +1478,7 @@ public void CommandTrainScoreEvaluateMultiClass() _step++; var outputFile2 = StdoutPath(); var metricsPath = MetricsPath(); - const string evalLoaderArgs = "loader=Text{header+ col=Label:TX:0 col=PredictedLabel:5 col=Score:6-8} xf=Term{col=Label} evaluator=MultiClass{score=Score}"; + const string evalLoaderArgs = "loader=Text{header+ col=Label:TX:0 col=PredictedLabel:5 col=Score:6-8} xf=Term{col=Label} evaluator=Multiclass{score=Score}"; TestCore("evaluate", scorePathTxt.Path, evalLoaderArgs, null, metricsPath.Arg("dout")); // Check that the evaluations produced the same result. @@ -1488,7 +1488,7 @@ public void CommandTrainScoreEvaluateMultiClass() //CheckEqualityFromPathsCore(TestContext.TestName, outputFile1.Path, outputFile2.Path); _step++; - const string evalLoaderArgs2 = "loader=Text{header+ col=Label:0 col=PredictedLabel:5 col=Score:6-8} evaluator=MultiClass{score=Score opcs+}"; + const string evalLoaderArgs2 = "loader=Text{header+ col=Label:0 col=PredictedLabel:5 col=Score:6-8} evaluator=Multiclass{score=Score opcs+}"; TestCore("evaluate", scorePathTxt.Path, evalLoaderArgs2, null, metricsPath.Arg("dout")); Done(); diff --git a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs index 609c0f202b..871eeb209f 100644 --- a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs +++ b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs @@ -89,7 +89,7 @@ private void ComparePredictions(PredictionEngine model Assert.Equal(0, prediction.PredictedLabels[2], 2); } - private void CompareMetrics(MultiClassClassifierMetrics metrics) + private void CompareMetrics(MulticlassClassificationMetrics metrics) { Assert.Equal(.98, metrics.MacroAccuracy); Assert.Equal(.98, metrics.MicroAccuracy, 2); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs index d5bbbd4094..9b0a1b329c 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs @@ -29,7 +29,7 @@ public void TestEstimatorLogisticRegression() [Fact] public void TestEstimatorMulticlassLogisticRegression() { - (IEstimator pipe, IDataView dataView) = GetMultiClassPipeline(); + (IEstimator pipe, IDataView dataView) = GetMulticlassPipeline(); var trainer = ML.MulticlassClassification.Trainers.LogisticRegression(); var pipeWithTrainer = pipe.Append(trainer); TestEstimatorCore(pipeWithTrainer, dataView); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs index ed907e4de0..e6f36351b5 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs @@ -19,7 +19,7 @@ public partial class TrainerEstimators [Fact] public void OVAWithAllConstructorArgs() { - var (pipeline, data) = GetMultiClassPipeline(); + var (pipeline, data) = GetMulticlassPipeline(); var calibrator = new PlattCalibratorEstimator(Env); var averagePerceptron = ML.BinaryClassification.Trainers.AveragedPerceptron( new AveragedPerceptronTrainer.Options { Shuffle = true }); @@ -40,7 +40,7 @@ public void OVAWithAllConstructorArgs() [Fact] public void OVAUncalibrated() { - var (pipeline, data) = GetMultiClassPipeline(); + var (pipeline, data) = GetMulticlassPipeline(); var sdcaTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( new SdcaNonCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 }); @@ -57,7 +57,7 @@ public void OVAUncalibrated() [Fact] public void PairwiseCouplingTrainer() { - var (pipeline, data) = GetMultiClassPipeline(); + var (pipeline, data) = GetMulticlassPipeline(); var sdcaTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( new SdcaNonCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 }); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs index 69b8aa0c1f..f5c5cab5e4 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs @@ -146,12 +146,12 @@ public void TestEstimatorHogwildSGDNonCalibrated() } /// - /// MultiClassNaiveBayes TrainerEstimator test + /// MulticlassNaiveBayes TrainerEstimator test /// [Fact] - public void TestEstimatorMultiClassNaiveBayesTrainer() + public void TestEstimatorMulticlassNaiveBayesTrainer() { - (IEstimator pipe, IDataView dataView) = GetMultiClassPipeline(); + (IEstimator pipe, IDataView dataView) = GetMulticlassPipeline(); pipe = pipe.Append(ML.MulticlassClassification.Trainers.NaiveBayes("Label", "Features")); TestEstimatorCore(pipe, dataView); Done(); @@ -230,7 +230,7 @@ private TextLoader.Options GetIrisLoaderArgs() }; } - private (IEstimator, IDataView) GetMultiClassPipeline() + private (IEstimator, IDataView) GetMulticlassPipeline() { var data = new TextLoader(Env, new TextLoader.Options() { diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs index 285651ec36..6d85c6ea7e 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs @@ -241,9 +241,9 @@ public void FastForestRegressorEstimator() /// LightGbmMulticlass TrainerEstimator test /// [LightGBMFact] - public void LightGbmMultiClassEstimator() + public void LightGbmMulticlassEstimator() { - var (pipeline, dataView) = GetMultiClassPipeline(); + var (pipeline, dataView) = GetMulticlassPipeline(); var trainer = ML.MulticlassClassification.Trainers.LightGbm(learningRate: 0.4); var pipe = pipeline.Append(trainer) .Append(new KeyToValueMappingEstimator(Env, "PredictedLabel")); @@ -373,7 +373,7 @@ private void LightGbmHelper(bool useSoftmax, out string modelString, out List mlnetPredictions, out double[] nativeResult1, out double[] nativeResult0); @@ -405,7 +405,7 @@ public void LightGbmMultiClassEstimatorCompareOva() } [LightGBMFact] - public void LightGbmMultiClassEstimatorCompareSoftMax() + public void LightGbmMulticlassEstimatorCompareSoftMax() { // Train ML.NET LightGBM and native LightGBM and apply the trained models to the training set. LightGbmHelper(useSoftmax: true, out string modelString, out List mlnetPredictions, out double[] nativeResult1, out double[] nativeResult0); @@ -438,7 +438,7 @@ public void LightGbmInDifferentCulture() { var currentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE"); - var (pipeline, dataView) = GetMultiClassPipeline(); + var (pipeline, dataView) = GetMulticlassPipeline(); var trainer = ML.MulticlassClassification.Trainers.LightGbm(learningRate: 0.4); var pipe = pipeline.Append(trainer) .Append(ML.Transforms.Conversion.MapKeyToValue("PredictedLabel"));