diff --git a/docs/code/MlNetCookBook.md b/docs/code/MlNetCookBook.md index f851941c24..babe2f73f5 100644 --- a/docs/code/MlNetCookBook.md +++ b/docs/code/MlNetCookBook.md @@ -244,7 +244,7 @@ We tried to make `Preview` debugger-friendly: our expectation is that, if you en Here is the code sample: ```csharp var estimator = mlContext.Transforms.Categorical.MapValueToKey("Label") - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()) + .Append(mlContext.MulticlassClassification.Trainers.Sdca()) .Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel")); var data = mlContext.Data.LoadFromTextFile(new TextLoader.Column[] { @@ -355,7 +355,7 @@ var pipeline = // once so adding a caching step before it is not helpful. .AppendCacheCheckpoint(mlContext) // Add the SDCA regression trainer. - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent(labelColumnName: "Target", featureColumnName: "FeatureVector")); + .Append(mlContext.Regression.Trainers.Sdca(labelColumnName: "Target", featureColumnName: "FeatureVector")); // Step three. Fit the pipeline to the training data. var model = pipeline.Fit(trainData); @@ -423,7 +423,7 @@ var pipeline = // Cache data in memory for steps after the cache check point stage. .AppendCacheCheckpoint(mlContext) // Use the multi-class SDCA model to predict the label using features. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()) + .Append(mlContext.MulticlassClassification.Trainers.Sdca()) // Apply the inverse conversion from 'PredictedLabel' column back to string value. .Append(mlContext.Transforms.Conversion.MapKeyToValue(("PredictedLabel", "Data"))); @@ -547,7 +547,7 @@ var pipeline = // Cache data in memory for steps after the cache check point stage. .AppendCacheCheckpoint(mlContext) // Use the multi-class SDCA model to predict the label using features. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.MulticlassClassification.Trainers.Sdca()); // Train the model. var trainedModel = pipeline.Fit(trainData); @@ -822,7 +822,7 @@ var pipeline = // Notice that unused part in the data may not be cached. .AppendCacheCheckpoint(mlContext) // Use the multi-class SDCA model to predict the label using features. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.MulticlassClassification.Trainers.Sdca()); // Split the data 90:10 into train and test sets, train and evaluate. var split = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/FeatureContributionCalculationTransform.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/FeatureContributionCalculationTransform.cs index 541e708cf7..1ce0bd63ba 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/FeatureContributionCalculationTransform.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/FeatureContributionCalculationTransform.cs @@ -22,7 +22,7 @@ public static void Example() var transformPipeline = mlContext.Transforms.Concatenate("Features", "CrimesPerCapita", "PercentResidental", "PercentNonRetail", "CharlesRiver", "NitricOxides", "RoomsPerDwelling", "PercentPre40s", "EmploymentDistance", "HighwayDistance", "TaxRate", "TeacherRatio"); - var learner = mlContext.Regression.Trainers.OrdinaryLeastSquares( + var learner = mlContext.Regression.Trainers.Ols( labelColumnName: "MedianHomeValue", featureColumnName: "Features"); var transformedData = transformPipeline.Fit(data).Transform(data); @@ -40,7 +40,7 @@ public static void Example() // FeatureContributionCalculatingEstimator can be use as an intermediary step in a pipeline. // The features retained by FeatureContributionCalculatingEstimator will be in the FeatureContribution column. var pipeline = mlContext.Model.Explainability.FeatureContributionCalculation(model.Model, model.FeatureColumn, numPositiveContributions: 11) - .Append(mlContext.Regression.Trainers.OrdinaryLeastSquares(featureColumnName: "FeatureContributions")); + .Append(mlContext.Regression.Trainers.Ols(featureColumnName: "FeatureContributions")); var outData = featureContributionCalculator.Fit(scoredData).Transform(scoredData); // Let's extract the weights from the linear model to use as a comparison diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/GeneralizedAdditiveModels.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/GeneralizedAdditiveModels.cs index 1a73bdad3c..5ab8fd3ad6 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/GeneralizedAdditiveModels.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/GeneralizedAdditiveModels.cs @@ -27,7 +27,7 @@ public static void Example() .Where(name => name != labelName) // Drop the Label .ToArray(); var pipeline = mlContext.Transforms.Concatenate("Features", featureNames) - .Append(mlContext.Regression.Trainers.GeneralizedAdditiveModels( + .Append(mlContext.Regression.Trainers.Gam( labelColumnName: labelName, featureColumnName: "Features", maximumBinCountPerFeature: 16)); var fitPipeline = pipeline.Fit(data); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/PermutationFeatureImportance/PFIRegressionExample.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/PermutationFeatureImportance/PFIRegressionExample.cs index b046f4a309..e14c9e2d08 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/PermutationFeatureImportance/PFIRegressionExample.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/PermutationFeatureImportance/PFIRegressionExample.cs @@ -20,7 +20,7 @@ public static void Example() // Then append a linear regression trainer. var pipeline = mlContext.Transforms.Concatenate("Features", featureNames) .Append(mlContext.Transforms.Normalize("Features")) - .Append(mlContext.Regression.Trainers.OrdinaryLeastSquares( + .Append(mlContext.Regression.Trainers.Ols( labelColumnName: labelName, featureColumnName: "Features")); var model = pipeline.Fit(data); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSample.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSample.cs index e9d8536a88..a42c760da0 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSample.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSample.cs @@ -29,7 +29,7 @@ public static void Example() var data = mlContext.Data.LoadFromEnumerable(samples); // Create an anomaly detector. Its underlying algorithm is randomized PCA. - var pipeline = mlContext.AnomalyDetection.Trainers.AnalyzeRandomizedPrincipalComponents(featureColumnName: nameof(DataPoint.Features), rank: 1, ensureZeroMean: false); + var pipeline = mlContext.AnomalyDetection.Trainers.RandomizedPca(featureColumnName: nameof(DataPoint.Features), rank: 1, ensureZeroMean: false); // Train the anomaly detector. var model = pipeline.Fit(data); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSampleWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSampleWithOptions.cs index 8aba2c8f84..f9160570c9 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSampleWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSampleWithOptions.cs @@ -28,7 +28,7 @@ public static void Example() // Convert the List to IDataView, a consumble format to ML.NET functions. var data = mlContext.Data.LoadFromEnumerable(samples); - var options = new ML.Trainers.RandomizedPrincipalComponentAnalyzer.Options() + var options = new ML.Trainers.RandomizedPcaTrainer.Options() { FeatureColumnName = nameof(DataPoint.Features), Rank = 1, @@ -36,7 +36,7 @@ public static void Example() }; // Create an anomaly detector. Its underlying algorithm is randomized PCA. - var pipeline = mlContext.AnomalyDetection.Trainers.AnalyzeRandomizedPrincipalComponents(options); + var pipeline = mlContext.AnomalyDetection.Trainers.RandomizedPca(options); // Train the anomaly detector. var model = pipeline.Fit(data); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs index cae0684039..5e7c2ae3ef 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachinewWithOptions.cs @@ -30,7 +30,7 @@ public static void Example() var pipeline = new EstimatorChain().AppendCacheCheckpoint(mlContext) .Append(mlContext.BinaryClassification.Trainers. FieldAwareFactorizationMachine( - new FieldAwareFactorizationMachineBinaryClassificationTrainer.Options + new FieldAwareFactorizationMachineTrainer.Options { FeatureColumnName = "Features", LabelColumnName = "Sentiment", diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscent.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscent.cs index 74d8f8445c..5c0756062b 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscent.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscent.cs @@ -49,7 +49,7 @@ public static void Example() // the "Features" column produced by FeaturizeText as the features column. var pipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features") .AppendCacheCheckpoint(mlContext) // Add a data-cache step within a pipeline. - .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(labelColumnName: "Sentiment", featureColumnName: "Features", l2Regularization: 0.001f)); + .Append(mlContext.BinaryClassification.Trainers.SdcaNonCalibrated(labelColumnName: "Sentiment", featureColumnName: "Features", l2Regularization: 0.001f)); // Step 3: Run Cross-Validation on this pipeline. var cvResults = mlContext.BinaryClassification.CrossValidate(data, pipeline, labelColumn: "Sentiment"); @@ -60,8 +60,8 @@ public static void Example() // If we wanted to specify more advanced parameters for the algorithm, // we could do so by tweaking the 'advancedSetting'. var advancedPipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features") - .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaBinaryTrainer.Options { + .Append(mlContext.BinaryClassification.Trainers.SdcaCalibrated( + new SdcaCalibratedBinaryClassificationTrainer.Options { LabelColumnName = "Sentiment", FeatureColumnName = "Features", ConvergenceTolerance = 0.01f, // The learning rate for adjusting bias from being regularized diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentNonCalibrated.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentNonCalibrated.cs index 6824892b6c..3459becb1c 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentNonCalibrated.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentNonCalibrated.cs @@ -40,7 +40,7 @@ public static void Example() // Step 2: Create a binary classifier. This trainer may produce a logistic regression model. // We set the "Label" column as the label of the dataset, and the "Features" column as the features column. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( + var pipeline = mlContext.BinaryClassification.Trainers.SdcaNonCalibrated( labelColumnName: "Label", featureColumnName: "Features", loss: new HingeLoss(), l2Regularization: 0.001f); // Step 3: Train the pipeline created. diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentWithOptions.cs index f9242829e3..c45393c658 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentWithOptions.cs @@ -22,7 +22,7 @@ public static void Example() var trainTestData = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); // Define the trainer options. - var options = new SdcaBinaryTrainer.Options() + var options = new SdcaCalibratedBinaryClassificationTrainer.Options() { // Make the convergence tolerance tighter. ConvergenceTolerance = 0.05f, @@ -33,7 +33,7 @@ public static void Example() }; // Create data training pipeline. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(options); + var pipeline = mlContext.BinaryClassification.Trainers.SdcaCalibrated(options); // Fit this pipeline to the training data. var model = pipeline.Fit(trainTestData.TrainSet); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescent.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescent.cs index 8fad192c44..b0e6f1b6c7 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescent.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescent.cs @@ -19,7 +19,7 @@ public static void Example() var trainTestData = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); // Create data training pipeline. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticGradientDescent(); + var pipeline = mlContext.BinaryClassification.Trainers.SgdCalibrated(); // Fit this pipeline to the training data. var model = pipeline.Fit(trainTestData.TrainSet); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibrated.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibrated.cs index 370c2c37c0..2d3dd293df 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibrated.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibrated.cs @@ -19,7 +19,7 @@ public static void Example() var trainTestData = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); // Create data training pipeline. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticGradientDescentNonCalibrated(); + var pipeline = mlContext.BinaryClassification.Trainers.SgdNonCalibrated(); // Fit this pipeline to the training data. var model = pipeline.Fit(trainTestData.TrainSet); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibratedWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibratedWithOptions.cs index 6a69f5952f..93ce6299dc 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibratedWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentNonCalibratedWithOptions.cs @@ -22,8 +22,8 @@ public static void Example() // Create data training pipeline. var pipeline = mlContext.BinaryClassification - .Trainers.StochasticGradientDescentNonCalibrated( - new SgdNonCalibratedBinaryTrainer.Options + .Trainers.SgdNonCalibrated( + new SgdNonCalibratedTrainer.Options { InitialLearningRate = 0.01, NumberOfIterations = 10, diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentWithOptions.cs index b65cc978ff..f03f620bde 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticGradientDescentWithOptions.cs @@ -21,7 +21,7 @@ public static void Example() var trainTestData = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); // Define the trainer options. - var options = new SgdBinaryTrainer.Options() + var options = new SgdCalibratedTrainer.Options() { // Make the convergence tolerance tighter. ConvergenceTolerance = 5e-5, @@ -32,7 +32,7 @@ public static void Example() }; // Create data training pipeline. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticGradientDescent(options); + var pipeline = mlContext.BinaryClassification.Trainers.SgdCalibrated(options); // Fit this pipeline to the training data. var model = pipeline.Fit(trainTestData.TrainSet); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescent.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescent.cs index 10496e4b25..4453f929d3 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescent.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescent.cs @@ -19,7 +19,7 @@ public static void Example() // Leave out 10% of data for testing. var split = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); // Create data training pipeline. - var pipeline = mlContext.BinaryClassification.Trainers.SymbolicStochasticGradientDescent(labelColumnName: "IsOver50K", numberOfIterations: 25); + var pipeline = mlContext.BinaryClassification.Trainers.SymbolicSgd(labelColumnName: "IsOver50K", numberOfIterations: 25); var model = pipeline.Fit(split.TrainSet); // Evaluate how the model is doing on the test data. diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescentWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescentWithOptions.cs index 99ea7f1460..bf5a836ecc 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescentWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SymbolicStochasticGradientDescentWithOptions.cs @@ -19,8 +19,8 @@ public static void Example() // Leave out 10% of data for testing. var split = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); // Create data training pipeline - var pipeline = mlContext.BinaryClassification.Trainers.SymbolicStochasticGradientDescent( - new ML.Trainers.SymbolicStochasticGradientDescentClassificationTrainer.Options() + var pipeline = mlContext.BinaryClassification.Trainers.SymbolicSgd( + new ML.Trainers.SymbolicSgdTrainer.Options() { LearningRate = 0.2f, NumberOfIterations = 10, diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Clustering/KMeansWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Clustering/KMeansWithOptions.cs index 2ffca06920..4aa171b7c3 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Clustering/KMeansWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Clustering/KMeansWithOptions.cs @@ -29,7 +29,7 @@ public static void Example() string outputColumnName = "Features"; var pipeline = ml.Transforms.Concatenate(outputColumnName, new[] { "Age", "Parity", "Induced" }) .Append(ml.Clustering.Trainers.KMeans( - new KMeansPlusPlusTrainer.Options + new KMeansTrainer.Options { FeatureColumnName = outputColumnName, NumberOfClusters = 2, diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscent.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscent.cs index b436fe502e..a318477344 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscent.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscent.cs @@ -30,7 +30,7 @@ public static void Example() // Convert the string labels into key types. mlContext.Transforms.Conversion.MapValueToKey("Label") // Apply StochasticDualCoordinateAscent multiclass trainer. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.MulticlassClassification.Trainers.Sdca()); // Split the data into training and test sets. Only training set is used in fitting // the created pipeline. Metrics are computed on the test. diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscentWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscentWithOptions.cs index 4d27a52e65..11363006ba 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscentWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscentWithOptions.cs @@ -26,7 +26,7 @@ public static void Example() // CC 1.216908,1.248052,1.391902,0.4326252,1.099942,0.9262842,1.334019,1.08762,0.9468155,0.4811099 // DD 0.7871246,1.053327,0.8971719,1.588544,1.242697,1.362964,0.6303943,0.9810045,0.9431419,1.557455 - var options = new SdcaMultiClassTrainer.Options + var options = new SdcaMulticlassClassificationTrainer.Options { // Add custom loss LossFunction = new HingeLoss(), @@ -41,7 +41,7 @@ public static void Example() // Convert the string labels into key types. mlContext.Transforms.Conversion.MapValueToKey("Label") // Apply StochasticDualCoordinateAscent multiclass trainer. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(options)); + .Append(mlContext.MulticlassClassification.Trainers.Sdca(options)); // Split the data into training and test sets. Only training set is used in fitting // the created pipeline. Metrics are computed on the test. diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquares.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquares.cs index 204322cec7..2d43970d17 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquares.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquares.cs @@ -43,7 +43,7 @@ public static void Example() // Create the estimator, here we only need OrdinaryLeastSquares trainer // as data is already processed in a form consumable by the trainer - var pipeline = mlContext.Regression.Trainers.OrdinaryLeastSquares(); + var pipeline = mlContext.Regression.Trainers.Ols(); var model = pipeline.Fit(split.TrainSet); diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquaresWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquaresWithOptions.cs index ccfa66aeb7..3d1af5555d 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquaresWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquaresWithOptions.cs @@ -44,7 +44,7 @@ public static void Example() // Create the estimator, here we only need OrdinaryLeastSquares trainer // as data is already processed in a form consumable by the trainer - var pipeline = mlContext.Regression.Trainers.OrdinaryLeastSquares(new OrdinaryLeastSquaresRegressionTrainer.Options() + var pipeline = mlContext.Regression.Trainers.Ols(new OlsTrainer.Options() { L2Regularization = 0.1f, CalculateStatistics = false diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscent.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscent.cs index c97c0e7be1..e674bec00c 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscent.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscent.cs @@ -22,7 +22,7 @@ public static void Example() var split = mlContext.Data.TrainTestSplit(dataView, testFraction: 0.1); // Train the model. - var pipeline = mlContext.Regression.Trainers.StochasticDualCoordinateAscent(); + var pipeline = mlContext.Regression.Trainers.Sdca(); var model = pipeline.Fit(split.TrainSet); // Do prediction on the test set. diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscentWithOptions.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscentWithOptions.cs index 2f55403e9a..c0110454a4 100644 --- a/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscentWithOptions.cs +++ b/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscentWithOptions.cs @@ -32,7 +32,7 @@ public static void Example() }; // Train the model. - var pipeline = mlContext.Regression.Trainers.StochasticDualCoordinateAscent(options); + var pipeline = mlContext.Regression.Trainers.Sdca(options); var model = pipeline.Fit(split.TrainSet); // Do prediction on the test set. diff --git a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs index 63ecef2e1e..526f23729a 100644 --- a/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs +++ b/src/Microsoft.ML.Ensemble/Trainer/Multiclass/MulticlassDataPartitionEnsembleTrainer.cs @@ -64,8 +64,8 @@ public Arguments() // non-default column names. Unfortuantely no method of resolving this temporary strikes me as being any // less laborious than the proper fix, which is that this "meta" component should itself be a trainer // estimator, as opposed to a regular trainer. - var trainerEstimator = new MulticlassLogisticRegression(env, LabelColumnName, FeatureColumnName); - return TrainerUtils.MapTrainerEstimatorToTrainer(env, trainerEstimator); }) }; diff --git a/src/Microsoft.ML.FastTree/FastTreeRegression.cs b/src/Microsoft.ML.FastTree/FastTreeRegression.cs index a5cbaa3ae4..ff36755b0e 100644 --- a/src/Microsoft.ML.FastTree/FastTreeRegression.cs +++ b/src/Microsoft.ML.FastTree/FastTreeRegression.cs @@ -391,7 +391,7 @@ internal sealed class ObjectiveImpl : ObjectiveFunctionBase, IStepSearch { private readonly float[] _labels; - public ObjectiveImpl(Dataset trainData, RegressionGamTrainer.Options options) : + public ObjectiveImpl(Dataset trainData, GamRegressionTrainer.Options options) : base( trainData, options.LearningRate, diff --git a/src/Microsoft.ML.FastTree/GamClassification.cs b/src/Microsoft.ML.FastTree/GamClassification.cs index 8a67f448ed..efedfc55d1 100644 --- a/src/Microsoft.ML.FastTree/GamClassification.cs +++ b/src/Microsoft.ML.FastTree/GamClassification.cs @@ -14,12 +14,12 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(BinaryClassificationGamTrainer.Summary, - typeof(BinaryClassificationGamTrainer), typeof(BinaryClassificationGamTrainer.Options), +[assembly: LoadableClass(GamBinaryClassificationTrainer.Summary, + typeof(GamBinaryClassificationTrainer), typeof(GamBinaryClassificationTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - BinaryClassificationGamTrainer.UserNameValue, - BinaryClassificationGamTrainer.LoadNameValue, - BinaryClassificationGamTrainer.ShortName, DocName = "trainer/GAM.md")] + GamBinaryClassificationTrainer.UserNameValue, + GamBinaryClassificationTrainer.LoadNameValue, + GamBinaryClassificationTrainer.ShortName, DocName = "trainer/GAM.md")] [assembly: LoadableClass(typeof(IPredictorProducing), typeof(BinaryClassificationGamModelParameters), null, typeof(SignatureLoadModel), "GAM Binary Class Predictor", @@ -27,8 +27,8 @@ namespace Microsoft.ML.Trainers.FastTree { - public sealed class BinaryClassificationGamTrainer : - GamTrainerBase>, CalibratedModelParametersBase> { @@ -48,16 +48,16 @@ public sealed class Options : OptionsBase private protected override bool NeedCalibration => true; /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal BinaryClassificationGamTrainer(IHostEnvironment env, Options options) + internal GamBinaryClassificationTrainer(IHostEnvironment env, Options options) : base(env, options, LoadNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { _sigmoidParameter = 1; } /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The private instance of . /// The name of the label column. @@ -66,7 +66,7 @@ internal BinaryClassificationGamTrainer(IHostEnvironment env, Options options) /// The number of iterations to use in learning the features. /// The learning rate. GAMs work best with a small learning rate. /// The maximum number of bins to use to approximate features - internal BinaryClassificationGamTrainer(IHostEnvironment env, + internal GamBinaryClassificationTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string rowGroupColumnName = null, @@ -142,7 +142,7 @@ private protected override BinaryPredictionTransformer new BinaryPredictionTransformer>(Host, model, trainSchema, FeatureColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public BinaryPredictionTransformer> Fit(IDataView trainData, IDataView validationData) diff --git a/src/Microsoft.ML.FastTree/GamRegression.cs b/src/Microsoft.ML.FastTree/GamRegression.cs index 7ad930c3c1..dce69c62d4 100644 --- a/src/Microsoft.ML.FastTree/GamRegression.cs +++ b/src/Microsoft.ML.FastTree/GamRegression.cs @@ -11,12 +11,12 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(RegressionGamTrainer.Summary, - typeof(RegressionGamTrainer), typeof(RegressionGamTrainer.Options), +[assembly: LoadableClass(GamRegressionTrainer.Summary, + typeof(GamRegressionTrainer), typeof(GamRegressionTrainer.Options), new[] { typeof(SignatureRegressorTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - RegressionGamTrainer.UserNameValue, - RegressionGamTrainer.LoadNameValue, - RegressionGamTrainer.ShortName, DocName = "trainer/GAM.md")] + GamRegressionTrainer.UserNameValue, + GamRegressionTrainer.LoadNameValue, + GamRegressionTrainer.ShortName, DocName = "trainer/GAM.md")] [assembly: LoadableClass(typeof(RegressionGamModelParameters), null, typeof(SignatureLoadModel), "GAM Regression Predictor", @@ -24,7 +24,7 @@ namespace Microsoft.ML.Trainers.FastTree { - public sealed class RegressionGamTrainer : GamTrainerBase, RegressionGamModelParameters> + public sealed class GamRegressionTrainer : GamTrainerBase, RegressionGamModelParameters> { public partial class Options : OptionsBase { @@ -39,7 +39,7 @@ public partial class Options : OptionsBase private protected override PredictionKind PredictionKind => PredictionKind.Regression; - internal RegressionGamTrainer(IHostEnvironment env, Options options) + internal GamRegressionTrainer(IHostEnvironment env, Options options) : base(env, options, LoadNameValue, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } /// @@ -52,7 +52,7 @@ internal RegressionGamTrainer(IHostEnvironment env, Options options) /// The number of iterations to use in learning the features. /// The learning rate. GAMs work best with a small learning rate. /// The maximum number of bins to use to approximate features - internal RegressionGamTrainer(IHostEnvironment env, + internal GamRegressionTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string rowGroupColumnName = null, @@ -91,7 +91,7 @@ private protected override RegressionPredictionTransformer new RegressionPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public RegressionPredictionTransformer Fit(IDataView trainData, IDataView validationData) diff --git a/src/Microsoft.ML.FastTree/GamTrainer.cs b/src/Microsoft.ML.FastTree/GamTrainer.cs index 4c607c2f1c..187bd9e806 100644 --- a/src/Microsoft.ML.FastTree/GamTrainer.cs +++ b/src/Microsoft.ML.FastTree/GamTrainer.cs @@ -663,30 +663,30 @@ public Stump(uint splitPoint, double lteValue, double gtValue) internal static class Gam { - [TlcModule.EntryPoint(Name = "Trainers.GeneralizedAdditiveModelRegressor", Desc = RegressionGamTrainer.Summary, UserName = RegressionGamTrainer.UserNameValue, ShortName = RegressionGamTrainer.ShortName)] - public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment env, RegressionGamTrainer.Options input) + [TlcModule.EntryPoint(Name = "Trainers.GeneralizedAdditiveModelRegressor", Desc = GamRegressionTrainer.Summary, UserName = GamRegressionTrainer.UserNameValue, ShortName = GamRegressionTrainer.ShortName)] + public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment env, GamRegressionTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainGAM"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return TrainerEntryPointsUtils.Train(host, input, - () => new RegressionGamTrainer(host, input), + return TrainerEntryPointsUtils.Train(host, input, + () => new GamRegressionTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } - [TlcModule.EntryPoint(Name = "Trainers.GeneralizedAdditiveModelBinaryClassifier", Desc = BinaryClassificationGamTrainer.Summary, UserName = BinaryClassificationGamTrainer.UserNameValue, ShortName = BinaryClassificationGamTrainer.ShortName)] - public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironment env, BinaryClassificationGamTrainer.Options input) + [TlcModule.EntryPoint(Name = "Trainers.GeneralizedAdditiveModelBinaryClassifier", Desc = GamBinaryClassificationTrainer.Summary, UserName = GamBinaryClassificationTrainer.UserNameValue, ShortName = GamBinaryClassificationTrainer.ShortName)] + public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironment env, GamBinaryClassificationTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainGAM"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return TrainerEntryPointsUtils.Train(host, input, - () => new BinaryClassificationGamTrainer(host, input), + return TrainerEntryPointsUtils.Train(host, input, + () => new GamBinaryClassificationTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } diff --git a/src/Microsoft.ML.FastTree/RandomForestClassification.cs b/src/Microsoft.ML.FastTree/RandomForestClassification.cs index a00b39df04..320eef56c6 100644 --- a/src/Microsoft.ML.FastTree/RandomForestClassification.cs +++ b/src/Microsoft.ML.FastTree/RandomForestClassification.cs @@ -14,12 +14,12 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(FastForestClassification.Summary, typeof(FastForestClassification), typeof(FastForestClassification.Options), +[assembly: LoadableClass(FastForestBinaryClassificationTrainer.Summary, typeof(FastForestBinaryClassificationTrainer), typeof(FastForestBinaryClassificationTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureTreeEnsembleTrainer), typeof(SignatureFeatureScorerTrainer) }, - FastForestClassification.UserNameValue, - FastForestClassification.LoadNameValue, + FastForestBinaryClassificationTrainer.UserNameValue, + FastForestBinaryClassificationTrainer.LoadNameValue, "FastForest", - FastForestClassification.ShortName, + FastForestBinaryClassificationTrainer.ShortName, "ffc")] [assembly: LoadableClass(typeof(IPredictorProducing), typeof(FastForestClassificationModelParameters), null, typeof(SignatureLoadModel), @@ -106,8 +106,8 @@ private static IPredictorProducing Create(IHostEnvironment env, ModelLoad } /// - public sealed partial class FastForestClassification : - RandomForestTrainerBase, FastForestClassificationModelParameters> + public sealed partial class FastForestBinaryClassificationTrainer : + RandomForestTrainerBase, FastForestClassificationModelParameters> { public sealed class Options : FastForestOptionsBase { @@ -132,7 +132,7 @@ public sealed class Options : FastForestOptionsBase private protected override bool NeedCalibration => true; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The private instance of . /// The name of the label column. @@ -141,7 +141,7 @@ public sealed class Options : FastForestOptionsBase /// The max number of leaves in each regression tree. /// Total number of decision trees to create in the ensemble. /// The minimal number of documents allowed in a leaf of a regression tree, out of the subsampled data. - internal FastForestClassification(IHostEnvironment env, + internal FastForestBinaryClassificationTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -155,11 +155,11 @@ internal FastForestClassification(IHostEnvironment env, } /// - /// Initializes a new instance of by using the class. + /// Initializes a new instance of by using the class. /// /// The instance of . /// Algorithm advanced settings. - internal FastForestClassification(IHostEnvironment env, Options options) + internal FastForestBinaryClassificationTrainer(IHostEnvironment env, Options options) : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { } @@ -211,7 +211,7 @@ private protected override BinaryPredictionTransformer new BinaryPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public BinaryPredictionTransformer Fit(IDataView trainData, IDataView validationData) @@ -249,18 +249,18 @@ protected override void GetGradientInOneQuery(int query, int threadIndex) internal static partial class FastForest { [TlcModule.EntryPoint(Name = "Trainers.FastForestBinaryClassifier", - Desc = FastForestClassification.Summary, - UserName = FastForestClassification.UserNameValue, - ShortName = FastForestClassification.ShortName)] - public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironment env, FastForestClassification.Options input) + Desc = FastForestBinaryClassificationTrainer.Summary, + UserName = FastForestBinaryClassificationTrainer.UserNameValue, + ShortName = FastForestBinaryClassificationTrainer.ShortName)] + public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironment env, FastForestBinaryClassificationTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainFastForest"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return TrainerEntryPointsUtils.Train(host, input, - () => new FastForestClassification(host, input), + return TrainerEntryPointsUtils.Train(host, input, + () => new FastForestBinaryClassificationTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName), diff --git a/src/Microsoft.ML.FastTree/RandomForestRegression.cs b/src/Microsoft.ML.FastTree/RandomForestRegression.cs index 9ee741b37f..049c608514 100644 --- a/src/Microsoft.ML.FastTree/RandomForestRegression.cs +++ b/src/Microsoft.ML.FastTree/RandomForestRegression.cs @@ -13,11 +13,11 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(FastForestRegression.Summary, typeof(FastForestRegression), typeof(FastForestRegression.Options), +[assembly: LoadableClass(FastForestRegressionTrainer.Summary, typeof(FastForestRegressionTrainer), typeof(FastForestRegressionTrainer.Options), new[] { typeof(SignatureRegressorTrainer), typeof(SignatureTrainer), typeof(SignatureTreeEnsembleTrainer), typeof(SignatureFeatureScorerTrainer) }, - FastForestRegression.UserNameValue, - FastForestRegression.LoadNameValue, - FastForestRegression.ShortName)] + FastForestRegressionTrainer.UserNameValue, + FastForestRegressionTrainer.LoadNameValue, + FastForestRegressionTrainer.ShortName)] [assembly: LoadableClass(typeof(FastForestRegressionModelParameters), null, typeof(SignatureLoadModel), "FastForest Regression Executor", @@ -243,8 +243,8 @@ ISchemaBindableMapper IQuantileRegressionPredictor.CreateMapper(Double[] quantil } /// - public sealed partial class FastForestRegression - : RandomForestTrainerBase, FastForestRegressionModelParameters> + public sealed partial class FastForestRegressionTrainer + : RandomForestTrainerBase, FastForestRegressionModelParameters> { public sealed class Options : FastForestOptionsBase { @@ -261,7 +261,7 @@ public sealed class Options : FastForestOptionsBase internal const string ShortName = "ffr"; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The private instance of . /// The name of the label column. @@ -270,7 +270,7 @@ public sealed class Options : FastForestOptionsBase /// The max number of leaves in each regression tree. /// Total number of decision trees to create in the ensemble. /// The minimal number of documents allowed in a leaf of a regression tree, out of the subsampled data. - internal FastForestRegression(IHostEnvironment env, + internal FastForestRegressionTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -284,11 +284,11 @@ internal FastForestRegression(IHostEnvironment env, } /// - /// Initializes a new instance of by using the class. + /// Initializes a new instance of by using the class. /// /// The instance of . /// Algorithm advanced settings. - internal FastForestRegression(IHostEnvironment env, Options options) + internal FastForestRegressionTrainer(IHostEnvironment env, Options options) : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName), true) { } @@ -331,7 +331,7 @@ private protected override RegressionPredictionTransformer new RegressionPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public RegressionPredictionTransformer Fit(IDataView trainData, IDataView validationData) @@ -425,18 +425,18 @@ public BasicImpl(Dataset trainData, Options options) internal static partial class FastForest { [TlcModule.EntryPoint(Name = "Trainers.FastForestRegressor", - Desc = FastForestRegression.Summary, - UserName = FastForestRegression.LoadNameValue, - ShortName = FastForestRegression.ShortName)] - public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment env, FastForestRegression.Options input) + Desc = FastForestRegressionTrainer.Summary, + UserName = FastForestRegressionTrainer.LoadNameValue, + ShortName = FastForestRegressionTrainer.ShortName)] + public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment env, FastForestRegressionTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainFastForest"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return TrainerEntryPointsUtils.Train(host, input, - () => new FastForestRegression(host, input), + return TrainerEntryPointsUtils.Train(host, input, + () => new FastForestRegressionTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.RowGroupColumnName)); diff --git a/src/Microsoft.ML.FastTree/TreeTrainersCatalog.cs b/src/Microsoft.ML.FastTree/TreeTrainersCatalog.cs index ee86489335..974aec4e3a 100644 --- a/src/Microsoft.ML.FastTree/TreeTrainersCatalog.cs +++ b/src/Microsoft.ML.FastTree/TreeTrainersCatalog.cs @@ -136,7 +136,7 @@ public static FastTreeRankingTrainer FastTree(this RankingCatalog.RankingTrainer } /// - /// Predict a target using generalized additive models trained with the . + /// Predict a target using generalized additive models (GAM) trained with the . /// /// The . /// The name of the label column. @@ -145,7 +145,7 @@ public static FastTreeRankingTrainer FastTree(this RankingCatalog.RankingTrainer /// The number of iterations to use in learning the features. /// The maximum number of bins to use to approximate features. /// The learning rate. GAMs work best with a small learning rate. - public static BinaryClassificationGamTrainer GeneralizedAdditiveModels(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static GamBinaryClassificationTrainer Gam(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -155,24 +155,24 @@ public static BinaryClassificationGamTrainer GeneralizedAdditiveModels(this Bina { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new BinaryClassificationGamTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, learningRate, maximumBinCountPerFeature); + return new GamBinaryClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, learningRate, maximumBinCountPerFeature); } /// - /// Predict a target using generalized additive models trained with the . + /// Predict a target using generalized additive models (GAM) trained with the . /// /// The . /// Algorithm advanced settings. - public static BinaryClassificationGamTrainer GeneralizedAdditiveModels(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - BinaryClassificationGamTrainer.Options options) + public static GamBinaryClassificationTrainer Gam(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + GamBinaryClassificationTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new BinaryClassificationGamTrainer(env, options); + return new GamBinaryClassificationTrainer(env, options); } /// - /// Predict a target using generalized additive models trained with the . + /// Predict a target using generalized additive models (GAM) trained with the . /// /// The . /// The name of the label column. @@ -181,7 +181,7 @@ public static BinaryClassificationGamTrainer GeneralizedAdditiveModels(this Bina /// The number of iterations to use in learning the features. /// The maximum number of bins to use to approximate features. /// The learning rate. GAMs work best with a small learning rate. - public static RegressionGamTrainer GeneralizedAdditiveModels(this RegressionCatalog.RegressionTrainers catalog, + public static GamRegressionTrainer Gam(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -191,20 +191,20 @@ public static RegressionGamTrainer GeneralizedAdditiveModels(this RegressionCata { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new RegressionGamTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, learningRate, maximumBinCountPerFeature); + return new GamRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, learningRate, maximumBinCountPerFeature); } /// - /// Predict a target using generalized additive models trained with the . + /// Predict a target using generalized additive models (GAM) trained with the . /// /// The . /// Algorithm advanced settings. - public static RegressionGamTrainer GeneralizedAdditiveModels(this RegressionCatalog.RegressionTrainers catalog, - RegressionGamTrainer.Options options) + public static GamRegressionTrainer Gam(this RegressionCatalog.RegressionTrainers catalog, + GamRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new RegressionGamTrainer(env, options); + return new GamRegressionTrainer(env, options); } /// @@ -248,7 +248,7 @@ public static FastTreeTweedieTrainer FastTreeTweedie(this RegressionCatalog.Regr } /// - /// Predict a target using a decision tree regression model trained with the . + /// Predict a target using a decision tree regression model trained with the . /// /// The . /// The name of the label column. @@ -257,7 +257,7 @@ public static FastTreeTweedieTrainer FastTreeTweedie(this RegressionCatalog.Regr /// The maximum number of leaves per decision tree. /// Total number of decision trees to create in the ensemble. /// The minimal number of datapoints allowed in a leaf of the tree, out of the subsampled data. - public static FastForestRegression FastForest(this RegressionCatalog.RegressionTrainers catalog, + public static FastForestRegressionTrainer FastForest(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -267,26 +267,26 @@ public static FastForestRegression FastForest(this RegressionCatalog.RegressionT { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new FastForestRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, numberOfTrees, minDatapointsInLeaves); + return new FastForestRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, numberOfTrees, minDatapointsInLeaves); } /// - /// Predict a target using a decision tree regression model trained with the . + /// Predict a target using a decision tree regression model trained with the . /// /// The . /// Algorithm advanced settings. - public static FastForestRegression FastForest(this RegressionCatalog.RegressionTrainers catalog, - FastForestRegression.Options options) + public static FastForestRegressionTrainer FastForest(this RegressionCatalog.RegressionTrainers catalog, + FastForestRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new FastForestRegression(env, options); + return new FastForestRegressionTrainer(env, options); } /// - /// Predict a target using a decision tree regression model trained with the . + /// Predict a target using a decision tree regression model trained with the . /// /// The . /// The name of the label column. @@ -295,7 +295,7 @@ public static FastForestRegression FastForest(this RegressionCatalog.RegressionT /// Total number of decision trees to create in the ensemble. /// The maximum number of leaves per decision tree. /// The minimal number of datapoints allowed in a leaf of the tree, out of the subsampled data. - public static FastForestClassification FastForest(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static FastForestBinaryClassificationTrainer FastForest(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -305,22 +305,22 @@ public static FastForestClassification FastForest(this BinaryClassificationCatal { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new FastForestClassification(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, numberOfTrees, minDatapointsInLeaves); + return new FastForestBinaryClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, numberOfTrees, minDatapointsInLeaves); } /// - /// Predict a target using a decision tree regression model trained with the . + /// Predict a target using a decision tree regression model trained with the . /// /// The . /// Algorithm advanced settings. - public static FastForestClassification FastForest(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - FastForestClassification.Options options) + public static FastForestBinaryClassificationTrainer FastForest(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + FastForestBinaryClassificationTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new FastForestClassification(env, options); + return new FastForestBinaryClassificationTrainer(env, options); } } } diff --git a/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs b/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs index 9d34af0464..8e2cdefcb1 100644 --- a/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs +++ b/src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs @@ -9,12 +9,12 @@ namespace Microsoft.ML { /// - /// The trainer context extensions for the . + /// The trainer context extensions for the . /// public static class KMeansClusteringExtensions { /// - /// Train a KMeans++ clustering algorithm using . + /// Train a KMeans++ clustering algorithm using . /// /// The clustering catalog trainer object. /// The name of the feature column. @@ -26,25 +26,25 @@ public static class KMeansClusteringExtensions /// [!code-csharp[KMeans](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Clustering/KMeans.cs)] /// ]]> /// - public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog, + public static KMeansTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, - int numberOfClusters = KMeansPlusPlusTrainer.Defaults.NumberOfClusters) + int numberOfClusters = KMeansTrainer.Defaults.NumberOfClusters) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - var options = new KMeansPlusPlusTrainer.Options + var options = new KMeansTrainer.Options { FeatureColumnName = featureColumnName, ExampleWeightColumnName = exampleWeightColumnName, NumberOfClusters = numberOfClusters }; - return new KMeansPlusPlusTrainer(env, options); + return new KMeansTrainer(env, options); } /// - /// Train a KMeans++ clustering algorithm using . + /// Train a KMeans++ clustering algorithm using . /// /// The clustering catalog trainer object. /// Algorithm advanced options. @@ -54,13 +54,13 @@ public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrai /// [!code-csharp[KMeans](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Clustering/KMeansWithOptions.cs)] /// ]]> /// - public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog, KMeansPlusPlusTrainer.Options options) + public static KMeansTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog, KMeansTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new KMeansPlusPlusTrainer(env, options); + return new KMeansTrainer(env, options); } } } diff --git a/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs b/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs index 2561f917a7..8cdd7ad82c 100644 --- a/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs +++ b/src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs @@ -17,18 +17,18 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(KMeansPlusPlusTrainer.Summary, typeof(KMeansPlusPlusTrainer), typeof(KMeansPlusPlusTrainer.Options), +[assembly: LoadableClass(KMeansTrainer.Summary, typeof(KMeansTrainer), typeof(KMeansTrainer.Options), new[] { typeof(SignatureClusteringTrainer), typeof(SignatureTrainer) }, - KMeansPlusPlusTrainer.UserNameValue, - KMeansPlusPlusTrainer.LoadNameValue, - KMeansPlusPlusTrainer.ShortName, "KMeans")] + KMeansTrainer.UserNameValue, + KMeansTrainer.LoadNameValue, + KMeansTrainer.ShortName, "KMeans")] -[assembly: LoadableClass(typeof(void), typeof(KMeansPlusPlusTrainer), null, typeof(SignatureEntryPointModule), "KMeans")] +[assembly: LoadableClass(typeof(void), typeof(KMeansTrainer), null, typeof(SignatureEntryPointModule), "KMeans")] namespace Microsoft.ML.Trainers { /// - public class KMeansPlusPlusTrainer : TrainerEstimatorBase, KMeansModelParameters> + public class KMeansTrainer : TrainerEstimatorBase, KMeansModelParameters> { internal const string LoadNameValue = "KMeansPlusPlus"; internal const string UserNameValue = "KMeans++ Clustering"; @@ -112,11 +112,11 @@ public sealed class Options : UnsupervisedTrainerInputBaseWithWeight private protected override PredictionKind PredictionKind => PredictionKind.Clustering; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The to use. /// The advanced options of the algorithm. - internal KMeansPlusPlusTrainer(IHostEnvironment env, Options options) + internal KMeansTrainer(IHostEnvironment env, Options options) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), default, TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName)) { Host.CheckValue(options, nameof(options)); @@ -245,7 +245,7 @@ internal static CommonOutputs.ClusteringOutput TrainKMeans(IHostEnvironment env, EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new KMeansPlusPlusTrainer(host, input), + () => new KMeansTrainer(host, input), getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } @@ -739,10 +739,10 @@ public static void Initialize(IHost host, int numThreads, IChannel ch, FeatureFl host.CheckValue(ch, nameof(ch)); ch.CheckValue(cursorFactory, nameof(cursorFactory)); ch.CheckValue(centroids, nameof(centroids)); - ch.CheckUserArg(numThreads > 0, nameof(KMeansPlusPlusTrainer.Options.NumberOfThreads), "Must be positive"); - ch.CheckUserArg(k > 0, nameof(KMeansPlusPlusTrainer.Options.NumberOfClusters), "Must be positive"); + ch.CheckUserArg(numThreads > 0, nameof(KMeansTrainer.Options.NumberOfThreads), "Must be positive"); + ch.CheckUserArg(k > 0, nameof(KMeansTrainer.Options.NumberOfClusters), "Must be positive"); ch.CheckParam(dimensionality > 0, nameof(dimensionality), "Must be positive"); - ch.CheckUserArg(accelMemBudgetMb >= 0, nameof(KMeansPlusPlusTrainer.Options.AccelerationMemoryBudgetMb), "Must be non-negative"); + ch.CheckUserArg(accelMemBudgetMb >= 0, nameof(KMeansTrainer.Options.AccelerationMemoryBudgetMb), "Must be non-negative"); int numRounds; int numSamplesPerRound; diff --git a/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs b/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs index 6e4ac7000e..290b7ba878 100644 --- a/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs +++ b/src/Microsoft.ML.LightGBM.StaticPipe/LightGbmStaticExtensions.cs @@ -16,7 +16,7 @@ namespace Microsoft.ML.LightGBM.StaticPipe public static class LightGbmStaticExtensions { /// - /// Predict a target using a tree regression model trained with the . + /// Predict a target using a tree regression model trained with the . /// /// The . /// The label column. @@ -51,7 +51,7 @@ public static Scalar LightGbm(this RegressionCatalog.RegressionTrainers c var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - var trainer = new LightGbmRegressorTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, + var trainer = new LightGbmRegressionTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -62,7 +62,7 @@ public static Scalar LightGbm(this RegressionCatalog.RegressionTrainers c } /// - /// Predict a target using a tree regression model trained with the . + /// Predict a target using a tree regression model trained with the . /// /// The . /// The label column. @@ -89,7 +89,7 @@ public static Scalar LightGbm(this RegressionCatalog.RegressionTrainers c options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new LightGbmRegressorTrainer(env, options); + var trainer = new LightGbmRegressionTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); return trainer; @@ -99,7 +99,7 @@ public static Scalar LightGbm(this RegressionCatalog.RegressionTrainers c } /// - /// Predict a target using a tree binary classification model trained with the . + /// Predict a target using a tree binary classification model trained with the . /// /// The . /// The label column. @@ -137,7 +137,7 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new LightGbmBinaryTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, + var trainer = new LightGbmBinaryClassificationTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); if (onFit != null) @@ -150,7 +150,7 @@ public static (Scalar score, Scalar probability, Scalar pred } /// - /// Predict a target using a tree binary classification model trained with the . + /// Predict a target using a tree binary classification model trained with the . /// /// The . /// The label column. @@ -178,7 +178,7 @@ public static (Scalar score, Scalar probability, Scalar pred options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new LightGbmBinaryTrainer(env, options); + var trainer = new LightGbmBinaryClassificationTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -279,7 +279,7 @@ public static Scalar LightGbm(this RankingCatalog.RankingTrainers c } /// - /// Predict a target using a tree multiclass classification model trained with the . + /// Predict a target using a tree multiclass classification model trained with the . /// /// The multiclass classification catalog trainer object. /// The label, or dependent variable. @@ -318,7 +318,7 @@ public static (Vector score, Key predictedLabel) var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new LightGbmMulticlassTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, + var trainer = new LightGbmMulticlassClassificationTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); if (onFit != null) @@ -330,7 +330,7 @@ public static (Vector score, Key predictedLabel) } /// - /// Predict a target using a tree multiclass classification model trained with the . + /// Predict a target using a tree multiclass classification model trained with the . /// /// The multiclass classification catalog trainer object. /// The label, or dependent variable. @@ -360,7 +360,7 @@ public static (Vector score, Key predictedLabel) options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new LightGbmMulticlassTrainer(env, options); + var trainer = new LightGbmMulticlassClassificationTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); diff --git a/src/Microsoft.ML.LightGBM/LightGbmArguments.cs b/src/Microsoft.ML.LightGBM/LightGbmArguments.cs index b522f15b28..1c3b554a29 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmArguments.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmArguments.cs @@ -151,7 +151,7 @@ public sealed class TreeBooster : BoosterParameter public class Options : ISupportBoosterParameterFactory { /// - /// Whether training data is unbalanced. Used by . + /// Whether training data is unbalanced. Used by . /// [Argument(ArgumentType.AtMostOnce, HelpText = "Use for binary classification when training data is not balanced.", ShortName = "us")] public bool UnbalancedSets = false; @@ -264,7 +264,7 @@ public class Options : ISupportBoosterParameterFactory public double L1Regularization = 0; /// - /// Controls the balance of positive and negative weights in . + /// Controls the balance of positive and negative weights in . /// /// /// This is useful for training on unbalanced data. A typical value to consider is sum(negative cases) / sum(positive cases). @@ -519,7 +519,7 @@ public enum EvalMetricType public EvalMetricType EvaluationMetric = EvalMetricType.DefaultMetric; /// - /// Whether to use softmax loss. Used only by . + /// Whether to use softmax loss. Used only by . /// [Argument(ArgumentType.AtMostOnce, HelpText = "Use softmax loss for the multi classification.")] [TlcModule.SweepableDiscreteParam("UseSoftmax", new object[] { true, false })] @@ -543,9 +543,9 @@ public enum EvalMetricType public string CustomGains = "0,3,7,15,31,63,127,255,511,1023,2047,4095"; /// - /// Parameter for the sigmoid function. Used only by , , and . + /// Parameter for the sigmoid function. Used only by , , and . /// - [Argument(ArgumentType.AtMostOnce, HelpText = "Parameter for the sigmoid function. Used only in " + nameof(LightGbmBinaryTrainer) + ", " + nameof(LightGbmMulticlassTrainer) + + [Argument(ArgumentType.AtMostOnce, HelpText = "Parameter for the sigmoid function. Used only in " + nameof(LightGbmBinaryClassificationTrainer) + ", " + nameof(LightGbmMulticlassClassificationTrainer) + " and in " + nameof(LightGbmRankingTrainer) + ".", ShortName = "sigmoid")] [TGUI(Label = "Sigmoid", SuggestedSweeps = "0.5,1")] public double Sigmoid = 0.5; diff --git a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs index 1c0fcce051..193c703a01 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs @@ -12,9 +12,9 @@ using Microsoft.ML.Trainers; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(LightGbmBinaryTrainer.Summary, typeof(LightGbmBinaryTrainer), typeof(Options), +[assembly: LoadableClass(LightGbmBinaryClassificationTrainer.Summary, typeof(LightGbmBinaryClassificationTrainer), typeof(Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureTreeEnsembleTrainer) }, - LightGbmBinaryTrainer.UserName, LightGbmBinaryTrainer.LoadNameValue, LightGbmBinaryTrainer.ShortName, DocName = "trainer/LightGBM.md")] + LightGbmBinaryClassificationTrainer.UserName, LightGbmBinaryClassificationTrainer.LoadNameValue, LightGbmBinaryClassificationTrainer.ShortName, DocName = "trainer/LightGBM.md")] [assembly: LoadableClass(typeof(IPredictorProducing), typeof(LightGbmBinaryModelParameters), null, typeof(SignatureLoadModel), "LightGBM Binary Executor", @@ -84,7 +84,7 @@ private static IPredictorProducing Create(IHostEnvironment env, ModelLoad /// The for training a boosted decision tree binary classification model using LightGBM. /// /// - public sealed class LightGbmBinaryTrainer : LightGbmTrainerBase>, CalibratedModelParametersBase> { @@ -95,13 +95,13 @@ public sealed class LightGbmBinaryTrainer : LightGbmTrainerBase PredictionKind.BinaryClassification; - internal LightGbmBinaryTrainer(IHostEnvironment env, Options options) + internal LightGbmBinaryClassificationTrainer(IHostEnvironment env, Options options) : base(env, LoadNameValue, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { } /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The private instance of . /// The name of The label column. @@ -111,7 +111,7 @@ internal LightGbmBinaryTrainer(IHostEnvironment env, Options options) /// The minimal number of data points allowed in a leaf of the tree, out of the subsampled data. /// The learning rate. /// Number of iterations. - internal LightGbmBinaryTrainer(IHostEnvironment env, + internal LightGbmBinaryClassificationTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -167,7 +167,7 @@ private protected override BinaryPredictionTransformer new BinaryPredictionTransformer>(Host, model, trainSchema, FeatureColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public BinaryPredictionTransformer> Fit(IDataView trainData, IDataView validationData) @@ -181,9 +181,9 @@ internal static partial class LightGbm { [TlcModule.EntryPoint( Name = "Trainers.LightGbmBinaryClassifier", - Desc = LightGbmBinaryTrainer.Summary, - UserName = LightGbmBinaryTrainer.UserName, - ShortName = LightGbmBinaryTrainer.ShortName)] + Desc = LightGbmBinaryClassificationTrainer.Summary, + UserName = LightGbmBinaryClassificationTrainer.UserName, + ShortName = LightGbmBinaryClassificationTrainer.ShortName)] public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironment env, Options input) { Contracts.CheckValue(env, nameof(env)); @@ -192,7 +192,7 @@ public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironm EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new LightGbmBinaryTrainer(host, input), + () => new LightGbmBinaryClassificationTrainer(host, input), getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } diff --git a/src/Microsoft.ML.LightGBM/LightGbmCatalog.cs b/src/Microsoft.ML.LightGBM/LightGbmCatalog.cs index 69f58495d6..af04a105b0 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmCatalog.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmCatalog.cs @@ -14,7 +14,7 @@ namespace Microsoft.ML public static class LightGbmExtensions { /// - /// Predict a target using a gradient boosting decision tree regression model trained with the . + /// Predict a target using a gradient boosting decision tree regression model trained with the . /// /// The . /// The name of the label column. @@ -31,7 +31,7 @@ public static class LightGbmExtensions /// ]]> /// /// - public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, + public static LightGbmRegressionTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -42,11 +42,11 @@ public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.Regressio { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LightGbmRegressorTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); + return new LightGbmRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); } /// - /// Predict a target using a gradient boosting decision tree regression model trained with the and advanced options. + /// Predict a target using a gradient boosting decision tree regression model trained with the and advanced options. /// /// The . /// Trainer options. @@ -57,16 +57,16 @@ public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.Regressio /// ]]> /// /// - public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, + public static LightGbmRegressionTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LightGbmRegressorTrainer(env, options); + return new LightGbmRegressionTrainer(env, options); } /// - /// Predict a target using a gradient boosting decision tree binary classification model trained with the . + /// Predict a target using a gradient boosting decision tree binary classification model trained with the . /// /// The . /// The name of the label column. @@ -83,7 +83,7 @@ public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.Regressio /// ]]> /// /// - public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static LightGbmBinaryClassificationTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -94,11 +94,11 @@ public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.Bi { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LightGbmBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); + return new LightGbmBinaryClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); } /// - /// Predict a target using a gradient boosting decision tree binary classification model trained with the and advanced options. + /// Predict a target using a gradient boosting decision tree binary classification model trained with the and advanced options. /// /// The . /// Trainer options. @@ -109,12 +109,12 @@ public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.Bi /// ]]> /// /// - public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static LightGbmBinaryClassificationTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LightGbmBinaryTrainer(env, options); + return new LightGbmBinaryClassificationTrainer(env, options); } /// @@ -172,7 +172,7 @@ public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainer } /// - /// Predict a target using a gradient boosting decision tree multiclass classification model trained with the . + /// Predict a target using a gradient boosting decision tree multiclass classification model trained with the . /// /// The . /// The name of the label column. @@ -189,7 +189,7 @@ public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainer /// ]]> /// /// - public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + public static LightGbmMulticlassClassificationTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -200,11 +200,11 @@ public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCa { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LightGbmMulticlassTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); + return new LightGbmMulticlassClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfLeaves, minimumExampleCountPerLeaf, learningRate, numberOfIterations); } /// - /// Predict a target using a gradient boosting decision tree multiclass classification model trained with the and advanced options. + /// Predict a target using a gradient boosting decision tree multiclass classification model trained with the and advanced options. /// /// The . /// Trainer options. @@ -215,12 +215,12 @@ public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCa /// ]]> /// /// - public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + public static LightGbmMulticlassClassificationTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LightGbmMulticlassTrainer(env, options); + return new LightGbmMulticlassClassificationTrainer(env, options); } } } diff --git a/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs index 7c221edf20..ca1190873b 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs @@ -14,9 +14,9 @@ using Microsoft.ML.Trainers; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(LightGbmMulticlassTrainer.Summary, typeof(LightGbmMulticlassTrainer), typeof(Options), +[assembly: LoadableClass(LightGbmMulticlassClassificationTrainer.Summary, typeof(LightGbmMulticlassClassificationTrainer), typeof(Options), new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, - "LightGBM Multi-class Classifier", LightGbmMulticlassTrainer.LoadNameValue, LightGbmMulticlassTrainer.ShortName, DocName = "trainer/LightGBM.md")] + "LightGBM Multi-class Classifier", LightGbmMulticlassClassificationTrainer.LoadNameValue, LightGbmMulticlassClassificationTrainer.ShortName, DocName = "trainer/LightGBM.md")] namespace Microsoft.ML.LightGBM { @@ -24,7 +24,7 @@ namespace Microsoft.ML.LightGBM /// The for training a boosted decision tree multi-class classification model using LightGBM. /// /// - public sealed class LightGbmMulticlassTrainer : LightGbmTrainerBase, MulticlassPredictionTransformer, OneVersusAllModelParameters> + public sealed class LightGbmMulticlassClassificationTrainer : LightGbmTrainerBase, MulticlassPredictionTransformer, OneVersusAllModelParameters> { internal const string Summary = "LightGBM Multi Class Classifier"; internal const string LoadNameValue = "LightGBMMulticlass"; @@ -36,14 +36,14 @@ public sealed class LightGbmMulticlassTrainer : LightGbmTrainerBase PredictionKind.MultiClassClassification; - internal LightGbmMulticlassTrainer(IHostEnvironment env, Options options) + internal LightGbmMulticlassClassificationTrainer(IHostEnvironment env, Options options) : base(env, LoadNameValue, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) { _numClass = -1; } /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The private instance of . /// The name of The label column. @@ -53,7 +53,7 @@ internal LightGbmMulticlassTrainer(IHostEnvironment env, Options options) /// The minimal number of data points allowed in a leaf of the tree, out of the subsampled data. /// The learning rate. /// The number of iterations to use. - internal LightGbmMulticlassTrainer(IHostEnvironment env, + internal LightGbmMulticlassClassificationTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -225,7 +225,7 @@ private protected override MulticlassPredictionTransformer new MulticlassPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name, LabelColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public MulticlassPredictionTransformer Fit(IDataView trainData, IDataView validationData) @@ -240,8 +240,8 @@ internal static partial class LightGbm [TlcModule.EntryPoint( Name = "Trainers.LightGbmClassifier", Desc = "Train a LightGBM multi class model.", - UserName = LightGbmMulticlassTrainer.Summary, - ShortName = LightGbmMulticlassTrainer.ShortName)] + UserName = LightGbmMulticlassClassificationTrainer.Summary, + ShortName = LightGbmMulticlassClassificationTrainer.ShortName)] public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, Options input) { Contracts.CheckValue(env, nameof(env)); @@ -250,7 +250,7 @@ public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHost EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new LightGbmMulticlassTrainer(host, input), + () => new LightGbmMulticlassClassificationTrainer(host, input), getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } diff --git a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs index 7d4b74a6df..67da0046ab 100644 --- a/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs +++ b/src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs @@ -11,9 +11,9 @@ using Microsoft.ML.Trainers; using Microsoft.ML.Trainers.FastTree; -[assembly: LoadableClass(LightGbmRegressorTrainer.Summary, typeof(LightGbmRegressorTrainer), typeof(Options), +[assembly: LoadableClass(LightGbmRegressionTrainer.Summary, typeof(LightGbmRegressionTrainer), typeof(Options), new[] { typeof(SignatureRegressorTrainer), typeof(SignatureTrainer), typeof(SignatureTreeEnsembleTrainer) }, - LightGbmRegressorTrainer.UserNameValue, LightGbmRegressorTrainer.LoadNameValue, LightGbmRegressorTrainer.ShortName, DocName = "trainer/LightGBM.md")] + LightGbmRegressionTrainer.UserNameValue, LightGbmRegressionTrainer.LoadNameValue, LightGbmRegressionTrainer.ShortName, DocName = "trainer/LightGBM.md")] [assembly: LoadableClass(typeof(LightGbmRegressionModelParameters), null, typeof(SignatureLoadModel), "LightGBM Regression Executor", @@ -76,7 +76,7 @@ private static LightGbmRegressionModelParameters Create(IHostEnvironment env, Mo /// The for training a boosted decision tree regression model using LightGBM. /// /// - public sealed class LightGbmRegressorTrainer : LightGbmTrainerBase, LightGbmRegressionModelParameters> + public sealed class LightGbmRegressionTrainer : LightGbmTrainerBase, LightGbmRegressionModelParameters> { internal const string Summary = "LightGBM Regression"; internal const string LoadNameValue = "LightGBMRegression"; @@ -86,7 +86,7 @@ public sealed class LightGbmRegressorTrainer : LightGbmTrainerBase PredictionKind.Regression; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The private instance of . /// The name of the label column. @@ -96,7 +96,7 @@ public sealed class LightGbmRegressorTrainer : LightGbmTrainerBaseThe minimal number of data points allowed in a leaf of the tree, out of the subsampled data. /// The learning rate. /// Number of iterations. - internal LightGbmRegressorTrainer(IHostEnvironment env, + internal LightGbmRegressionTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -108,7 +108,7 @@ internal LightGbmRegressorTrainer(IHostEnvironment env, { } - internal LightGbmRegressorTrainer(IHostEnvironment env, Options options) + internal LightGbmRegressionTrainer(IHostEnvironment env, Options options) : base(env, LoadNameValue, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -153,7 +153,7 @@ private protected override RegressionPredictionTransformer new RegressionPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Trains a using both training and validation data, returns + /// Trains a using both training and validation data, returns /// a . /// public RegressionPredictionTransformer Fit(IDataView trainData, IDataView validationData) @@ -166,9 +166,9 @@ public RegressionPredictionTransformer Fit(ID internal static partial class LightGbm { [TlcModule.EntryPoint(Name = "Trainers.LightGbmRegressor", - Desc = LightGbmRegressorTrainer.Summary, - UserName = LightGbmRegressorTrainer.UserNameValue, - ShortName = LightGbmRegressorTrainer.ShortName)] + Desc = LightGbmRegressionTrainer.Summary, + UserName = LightGbmRegressionTrainer.UserNameValue, + ShortName = LightGbmRegressionTrainer.ShortName)] public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment env, Options input) { Contracts.CheckValue(env, nameof(env)); @@ -177,7 +177,7 @@ public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment en EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new LightGbmRegressorTrainer(host, input), + () => new LightGbmRegressionTrainer(host, input), getLabel: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } diff --git a/src/Microsoft.ML.Mkl.Components/ComputeLRTrainingStdThroughHal.cs b/src/Microsoft.ML.Mkl.Components/ComputeLRTrainingStdThroughHal.cs index 02bc7e11d2..aec953c79e 100644 --- a/src/Microsoft.ML.Mkl.Components/ComputeLRTrainingStdThroughHal.cs +++ b/src/Microsoft.ML.Mkl.Components/ComputeLRTrainingStdThroughHal.cs @@ -10,7 +10,7 @@ namespace Microsoft.ML.Trainers { - using MklOls = OrdinaryLeastSquaresRegressionTrainer.Mkl; + using MklOls = OlsTrainer.Mkl; public sealed class ComputeLRTrainingStdThroughMkl : ComputeLogisticRegressionStandardDeviation { diff --git a/src/Microsoft.ML.Mkl.Components/MklComponentsCatalog.cs b/src/Microsoft.ML.Mkl.Components/MklComponentsCatalog.cs index b6b1fbc43c..7ba5c81031 100644 --- a/src/Microsoft.ML.Mkl.Components/MklComponentsCatalog.cs +++ b/src/Microsoft.ML.Mkl.Components/MklComponentsCatalog.cs @@ -10,12 +10,13 @@ namespace Microsoft.ML { /// - /// The trainer catalog extensions for the and . + /// The trainer catalog extensions for the and . /// public static class MklComponentsCatalog { /// - /// Predict a target using a linear regression model trained with the . + /// Predict a target using a linear regression model trained with the . + /// It uses ordinary least squares (OLS) for estimating the parameters of the linear regression model. /// /// The . /// The name of the label column. @@ -28,28 +29,29 @@ public static class MklComponentsCatalog /// ]]> /// /// - public static OrdinaryLeastSquaresRegressionTrainer OrdinaryLeastSquares(this RegressionCatalog.RegressionTrainers catalog, + public static OlsTrainer Ols(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - var options = new OrdinaryLeastSquaresRegressionTrainer.Options + var options = new OlsTrainer.Options { LabelColumnName = labelColumnName, FeatureColumnName = featureColumnName, ExampleWeightColumnName = exampleWeightColumnName }; - return new OrdinaryLeastSquaresRegressionTrainer(env, options); + return new OlsTrainer(env, options); } /// - /// Predict a target using a linear regression model trained with the . + /// Predict a target using a linear regression model trained with the . + /// It uses ordinary least squares (OLS) for estimating the parameters of the linear regression model. /// /// The . - /// Algorithm advanced options. See . + /// Algorithm advanced options. See . /// /// /// /// /// - public static OrdinaryLeastSquaresRegressionTrainer OrdinaryLeastSquares( + public static OlsTrainer Ols( this RegressionCatalog.RegressionTrainers catalog, - OrdinaryLeastSquaresRegressionTrainer.Options options) + OlsTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new OrdinaryLeastSquaresRegressionTrainer(env, options); + return new OlsTrainer(env, options); } /// - /// Predict a target using a linear binary classification model trained with the . + /// Predict a target using a linear binary classification model trained with the . + /// Stochastic gradient descent (SGD) is an iterative algorithm that optimizes a differentiable objective function. + /// The parallelizes SGD using symbolic execution. /// /// The . /// The name of the label column. @@ -82,28 +86,30 @@ public static OrdinaryLeastSquaresRegressionTrainer OrdinaryLeastSquares( /// ]]> /// /// - public static SymbolicStochasticGradientDescentClassificationTrainer SymbolicStochasticGradientDescent(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static SymbolicSgdTrainer SymbolicSgd(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, - int numberOfIterations = SymbolicStochasticGradientDescentClassificationTrainer.Defaults.NumberOfIterations) + int numberOfIterations = SymbolicSgdTrainer.Defaults.NumberOfIterations) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - var options = new SymbolicStochasticGradientDescentClassificationTrainer.Options + var options = new SymbolicSgdTrainer.Options { LabelColumnName = labelColumnName, FeatureColumnName = featureColumnName, }; - return new SymbolicStochasticGradientDescentClassificationTrainer(env, options); + return new SymbolicSgdTrainer(env, options); } /// - /// Predict a target using a linear binary classification model trained with the . + /// Predict a target using a linear binary classification model trained with the . + /// Stochastic gradient descent (SGD) is an iterative algorithm that optimizes a differentiable objective function. + /// The parallelizes SGD using symbolic execution. /// /// The . - /// Algorithm advanced options. See . + /// Algorithm advanced options. See . /// /// /// /// /// - public static SymbolicStochasticGradientDescentClassificationTrainer SymbolicStochasticGradientDescent( + public static SymbolicSgdTrainer SymbolicSgd( this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - SymbolicStochasticGradientDescentClassificationTrainer.Options options) + SymbolicSgdTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new SymbolicStochasticGradientDescentClassificationTrainer(env, options); + return new SymbolicSgdTrainer(env, options); } /// diff --git a/src/Microsoft.ML.Mkl.Components/OlsLinearRegression.cs b/src/Microsoft.ML.Mkl.Components/OlsLinearRegression.cs index 2e94bea742..377cbfadf5 100644 --- a/src/Microsoft.ML.Mkl.Components/OlsLinearRegression.cs +++ b/src/Microsoft.ML.Mkl.Components/OlsLinearRegression.cs @@ -18,22 +18,22 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(OrdinaryLeastSquaresRegressionTrainer.Summary, typeof(OrdinaryLeastSquaresRegressionTrainer), typeof(OrdinaryLeastSquaresRegressionTrainer.Options), +[assembly: LoadableClass(OlsTrainer.Summary, typeof(OlsTrainer), typeof(OlsTrainer.Options), new[] { typeof(SignatureRegressorTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - OrdinaryLeastSquaresRegressionTrainer.UserNameValue, - OrdinaryLeastSquaresRegressionTrainer.LoadNameValue, - OrdinaryLeastSquaresRegressionTrainer.ShortName)] + OlsTrainer.UserNameValue, + OlsTrainer.LoadNameValue, + OlsTrainer.ShortName)] [assembly: LoadableClass(typeof(OrdinaryLeastSquaresRegressionModelParameters), null, typeof(SignatureLoadModel), "OLS Linear Regression Executor", OrdinaryLeastSquaresRegressionModelParameters.LoaderSignature)] -[assembly: LoadableClass(typeof(void), typeof(OrdinaryLeastSquaresRegressionTrainer), null, typeof(SignatureEntryPointModule), OrdinaryLeastSquaresRegressionTrainer.LoadNameValue)] +[assembly: LoadableClass(typeof(void), typeof(OlsTrainer), null, typeof(SignatureEntryPointModule), OlsTrainer.LoadNameValue)] namespace Microsoft.ML.Trainers { /// - public sealed class OrdinaryLeastSquaresRegressionTrainer : TrainerEstimatorBase, OrdinaryLeastSquaresRegressionModelParameters> + public sealed class OlsTrainer : TrainerEstimatorBase, OrdinaryLeastSquaresRegressionModelParameters> { /// Advanced options for trainer. public sealed class Options : TrainerInputBaseWithWeight @@ -74,9 +74,9 @@ public sealed class Options : TrainerInputBaseWithWeight public override TrainerInfo Info => _info; /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal OrdinaryLeastSquaresRegressionTrainer(IHostEnvironment env, Options options) + internal OlsTrainer(IHostEnvironment env, Options options) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName), TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName)) { @@ -501,7 +501,7 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment EntryPointUtils.CheckInputArgs(host, options); return TrainerEntryPointsUtils.Train(host, options, - () => new OrdinaryLeastSquaresRegressionTrainer(host, options), + () => new OlsTrainer(host, options), () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.ExampleWeightColumnName)); } @@ -546,7 +546,7 @@ private static VersionInfo GetVersionInfo() /// are all null. A model may not have per parameter statistics because either /// there were not more examples than parameters in the model, or because they /// were explicitly suppressed in training by setting - /// + /// /// to false. /// public bool HasStatistics => StandardErrors != null; diff --git a/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs b/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs index 397b01f778..2182173fa5 100644 --- a/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs +++ b/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs @@ -20,20 +20,20 @@ using Microsoft.ML.Trainers; using Microsoft.ML.Transforms; -[assembly: LoadableClass(typeof(SymbolicStochasticGradientDescentClassificationTrainer), typeof(SymbolicStochasticGradientDescentClassificationTrainer.Options), +[assembly: LoadableClass(typeof(SymbolicSgdTrainer), typeof(SymbolicSgdTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - SymbolicStochasticGradientDescentClassificationTrainer.UserNameValue, - SymbolicStochasticGradientDescentClassificationTrainer.LoadNameValue, - SymbolicStochasticGradientDescentClassificationTrainer.ShortName)] + SymbolicSgdTrainer.UserNameValue, + SymbolicSgdTrainer.LoadNameValue, + SymbolicSgdTrainer.ShortName)] -[assembly: LoadableClass(typeof(void), typeof(SymbolicStochasticGradientDescentClassificationTrainer), null, typeof(SignatureEntryPointModule), SymbolicStochasticGradientDescentClassificationTrainer.LoadNameValue)] +[assembly: LoadableClass(typeof(void), typeof(SymbolicSgdTrainer), null, typeof(SignatureEntryPointModule), SymbolicSgdTrainer.LoadNameValue)] namespace Microsoft.ML.Trainers { using TPredictor = CalibratedModelParametersBase; /// - public sealed class SymbolicStochasticGradientDescentClassificationTrainer : TrainerEstimatorBase, TPredictor> + public sealed class SymbolicSgdTrainer : TrainerEstimatorBase, TPredictor> { internal const string LoadNameValue = "SymbolicSGD"; internal const string UserNameValue = "Symbolic SGD (binary)"; @@ -196,9 +196,9 @@ private protected override TPredictor TrainModelCore(TrainContext context) private protected override PredictionKind PredictionKind => PredictionKind.BinaryClassification; /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal SymbolicStochasticGradientDescentClassificationTrainer(IHostEnvironment env, Options options) + internal SymbolicSgdTrainer(IHostEnvironment env, Options options) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { @@ -224,7 +224,7 @@ private protected override BinaryPredictionTransformer MakeTransform => new BinaryPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Continues the training of using an already trained + /// Continues the training of using an already trained /// a . /// public BinaryPredictionTransformer Fit(IDataView trainData, LinearModelParameters modelParameters) @@ -242,8 +242,8 @@ private protected override SchemaShape.Column[] GetOutputColumnsCore(SchemaShape [TlcModule.EntryPoint(Name = "Trainers.SymSgdBinaryClassifier", Desc = "Train a symbolic SGD.", - UserName = SymbolicStochasticGradientDescentClassificationTrainer.UserNameValue, - ShortName = SymbolicStochasticGradientDescentClassificationTrainer.ShortName)] + UserName = SymbolicSgdTrainer.UserNameValue, + ShortName = SymbolicSgdTrainer.ShortName)] internal static CommonOutputs.BinaryClassificationOutput TrainSymSgd(IHostEnvironment env, Options options) { Contracts.CheckValue(env, nameof(env)); @@ -252,7 +252,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainSymSgd(IHostEnviro EntryPointUtils.CheckInputArgs(host, options); return TrainerEntryPointsUtils.Train(host, options, - () => new SymbolicStochasticGradientDescentClassificationTrainer(host, options), + () => new SymbolicSgdTrainer(host, options), () => TrainerEntryPointsUtils.FindColumn(host, options.TrainingData.Schema, options.LabelColumnName)); } @@ -325,7 +325,7 @@ public void Free() // giving an array, we are at _storage[_storageIndex][_indexInCurArray]. private int _indexInCurArray; // This is used to access AccelMemBudget, AccelChunkSize and UsedMemory - private readonly SymbolicStochasticGradientDescentClassificationTrainer _trainer; + private readonly SymbolicSgdTrainer _trainer; private readonly IChannel _ch; @@ -337,7 +337,7 @@ public void Free() /// /// /// - public ArrayManager(SymbolicStochasticGradientDescentClassificationTrainer trainer, IChannel ch) + public ArrayManager(SymbolicSgdTrainer trainer, IChannel ch) { _storage = new List(); // Setting the default value to 2^17. @@ -501,7 +501,7 @@ private sealed class InputDataManager : IDisposable // This is the index to go over the instances in instanceProperties private int _instanceIndex; // This is used to access AccelMemBudget, AccelChunkSize and UsedMemory - private readonly SymbolicStochasticGradientDescentClassificationTrainer _trainer; + private readonly SymbolicSgdTrainer _trainer; private readonly IChannel _ch; // Whether memorySize was big enough to load the entire instances into the buffer @@ -512,7 +512,7 @@ private sealed class InputDataManager : IDisposable // Tells if we have gone through the dataset entirely. public bool FinishedTheLoad => !_cursorMoveNext; - public InputDataManager(SymbolicStochasticGradientDescentClassificationTrainer trainer, FloatLabelCursor.Factory cursorFactory, IChannel ch) + public InputDataManager(SymbolicSgdTrainer trainer, FloatLabelCursor.Factory cursorFactory, IChannel ch) { _instIndices = new ArrayManager(trainer, ch); _instValues = new ArrayManager(trainer, ch); diff --git a/src/Microsoft.ML.PCA/PCACatalog.cs b/src/Microsoft.ML.PCA/PCACatalog.cs index be6c13ff4d..2cf6f5e1bb 100644 --- a/src/Microsoft.ML.PCA/PCACatalog.cs +++ b/src/Microsoft.ML.PCA/PCACatalog.cs @@ -6,7 +6,7 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; using Microsoft.ML.Transforms; -using static Microsoft.ML.Trainers.RandomizedPrincipalComponentAnalyzer; +using static Microsoft.ML.Trainers.RandomizedPcaTrainer; namespace Microsoft.ML { @@ -39,7 +39,7 @@ public static PrincipalComponentAnalyzer ProjectToPrincipalComponents(this Trans => new PrincipalComponentAnalyzer(CatalogUtils.GetEnvironment(catalog), columns); /// - /// Trains an approximate PCA using Randomized SVD algorithm. + /// Trains an approximate principal component analysis (PCA) model using randomized SVD algorithm. /// /// The anomaly detection catalog trainer object. /// The name of the feature column. @@ -54,7 +54,7 @@ public static PrincipalComponentAnalyzer ProjectToPrincipalComponents(this Trans /// [!code-csharp[RPCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSample.cs)] /// ]]> /// - public static RandomizedPrincipalComponentAnalyzer AnalyzeRandomizedPrincipalComponents(this AnomalyDetectionCatalog.AnomalyDetectionTrainers catalog, + public static RandomizedPcaTrainer RandomizedPca(this AnomalyDetectionCatalog.AnomalyDetectionTrainers catalog, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, int rank = Options.Defaults.NumComponents, @@ -64,11 +64,11 @@ public static RandomizedPrincipalComponentAnalyzer AnalyzeRandomizedPrincipalCom { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new RandomizedPrincipalComponentAnalyzer(env, featureColumnName, exampleWeightColumnName, rank, oversampling, ensureZeroMean, seed); + return new RandomizedPcaTrainer(env, featureColumnName, exampleWeightColumnName, rank, oversampling, ensureZeroMean, seed); } /// - /// Trains an approximate PCA using Randomized SVD algorithm. + /// Trains an approximate principal component analysis (PCA) model using randomized SVD algorithm. /// /// The anomaly detection catalog trainer object. /// Advanced options to the algorithm. @@ -78,11 +78,11 @@ public static RandomizedPrincipalComponentAnalyzer AnalyzeRandomizedPrincipalCom /// [!code-csharp[RPCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/AnomalyDetection/RandomizedPcaSampleWithOptions.cs)] /// ]]> /// - public static RandomizedPrincipalComponentAnalyzer AnalyzeRandomizedPrincipalComponents(this AnomalyDetectionCatalog.AnomalyDetectionTrainers catalog, Options options) + public static RandomizedPcaTrainer RandomizedPca(this AnomalyDetectionCatalog.AnomalyDetectionTrainers catalog, Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new RandomizedPrincipalComponentAnalyzer(env, options); + return new RandomizedPcaTrainer(env, options); } } } diff --git a/src/Microsoft.ML.PCA/PcaTrainer.cs b/src/Microsoft.ML.PCA/PcaTrainer.cs index 1ea09467df..4d0e7a4cac 100644 --- a/src/Microsoft.ML.PCA/PcaTrainer.cs +++ b/src/Microsoft.ML.PCA/PcaTrainer.cs @@ -18,16 +18,16 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(RandomizedPrincipalComponentAnalyzer.Summary, typeof(RandomizedPrincipalComponentAnalyzer), typeof(RandomizedPrincipalComponentAnalyzer.Options), +[assembly: LoadableClass(RandomizedPcaTrainer.Summary, typeof(RandomizedPcaTrainer), typeof(RandomizedPcaTrainer.Options), new[] { typeof(SignatureAnomalyDetectorTrainer), typeof(SignatureTrainer) }, - RandomizedPrincipalComponentAnalyzer.UserNameValue, - RandomizedPrincipalComponentAnalyzer.LoadNameValue, - RandomizedPrincipalComponentAnalyzer.ShortName)] + RandomizedPcaTrainer.UserNameValue, + RandomizedPcaTrainer.LoadNameValue, + RandomizedPcaTrainer.ShortName)] [assembly: LoadableClass(typeof(PrincipleComponentModelParameters), null, typeof(SignatureLoadModel), "PCA Anomaly Executor", PrincipleComponentModelParameters.LoaderSignature)] -[assembly: LoadableClass(typeof(void), typeof(RandomizedPrincipalComponentAnalyzer), null, typeof(SignatureEntryPointModule), RandomizedPrincipalComponentAnalyzer.LoadNameValue)] +[assembly: LoadableClass(typeof(void), typeof(RandomizedPcaTrainer), null, typeof(SignatureEntryPointModule), RandomizedPcaTrainer.LoadNameValue)] namespace Microsoft.ML.Trainers { @@ -40,7 +40,7 @@ namespace Microsoft.ML.Trainers /// /// This PCA can be made into Kernel PCA by using Random Fourier Features transform /// - public sealed class RandomizedPrincipalComponentAnalyzer : TrainerEstimatorBase, PrincipleComponentModelParameters> + public sealed class RandomizedPcaTrainer : TrainerEstimatorBase, PrincipleComponentModelParameters> { internal const string LoadNameValue = "pcaAnomaly"; internal const string UserNameValue = "PCA Anomaly Detector"; @@ -88,7 +88,7 @@ internal static class Defaults public override TrainerInfo Info => _info; /// - /// Initializes a new instance of . + /// Initializes a new instance of . /// /// The local instance of the . /// The name of the feature column. @@ -97,7 +97,7 @@ internal static class Defaults /// Oversampling parameter for randomized PCA training. /// If enabled, data is centered to be zero mean. /// The seed for random number generation. - internal RandomizedPrincipalComponentAnalyzer(IHostEnvironment env, + internal RandomizedPcaTrainer(IHostEnvironment env, string featureColumnName, string exampleWeightColumnName = null, int rank = Options.Defaults.NumComponents, @@ -108,12 +108,12 @@ internal RandomizedPrincipalComponentAnalyzer(IHostEnvironment env, { } - internal RandomizedPrincipalComponentAnalyzer(IHostEnvironment env, Options options) + internal RandomizedPcaTrainer(IHostEnvironment env, Options options) : this(env, options, options.FeatureColumnName, options.ExampleWeightColumnName) { } - private RandomizedPrincipalComponentAnalyzer(IHostEnvironment env, Options options, string featureColumnName, string exampleWeightColumnName, + private RandomizedPcaTrainer(IHostEnvironment env, Options options, string featureColumnName, string exampleWeightColumnName, int rank = 20, int oversampling = 20, bool center = true, int? seed = null) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(featureColumnName), default, TrainerUtils.MakeR4ScalarWeightColumn(exampleWeightColumnName)) { @@ -359,7 +359,7 @@ internal static CommonOutputs.AnomalyDetectionOutput TrainPcaAnomaly(IHostEnviro EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new RandomizedPrincipalComponentAnalyzer(host, input), + () => new RandomizedPcaTrainer(host, input), getWeight: () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } } diff --git a/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineCatalog.cs b/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineCatalog.cs index c0dbce1724..f241288678 100644 --- a/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineCatalog.cs +++ b/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineCatalog.cs @@ -9,7 +9,7 @@ namespace Microsoft.ML { /// - /// Extension method to create + /// Extension method to create /// public static class FactorizationMachineExtensions { @@ -26,14 +26,14 @@ public static class FactorizationMachineExtensions /// [!code-csharp[FieldAwareFactorizationMachine](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachine.cs)] /// ]]> /// - public static FieldAwareFactorizationMachineBinaryClassificationTrainer FieldAwareFactorizationMachine(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static FieldAwareFactorizationMachineTrainer FieldAwareFactorizationMachine(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string[] featureColumnNames, string labelColumnName = DefaultColumnNames.Label, string exampleWeightColumnName = null) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new FieldAwareFactorizationMachineBinaryClassificationTrainer(env, featureColumnNames, labelColumnName, exampleWeightColumnName); + return new FieldAwareFactorizationMachineTrainer(env, featureColumnNames, labelColumnName, exampleWeightColumnName); } /// @@ -47,12 +47,12 @@ public static FieldAwareFactorizationMachineBinaryClassificationTrainer FieldAwa /// [!code-csharp[FieldAwareFactorizationMachine](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/FieldAwareFactorizationMachineWithOptions.cs)] /// ]]> /// - public static FieldAwareFactorizationMachineBinaryClassificationTrainer FieldAwareFactorizationMachine(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - FieldAwareFactorizationMachineBinaryClassificationTrainer.Options options) + public static FieldAwareFactorizationMachineTrainer FieldAwareFactorizationMachine(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + FieldAwareFactorizationMachineTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new FieldAwareFactorizationMachineBinaryClassificationTrainer(env, options); + return new FieldAwareFactorizationMachineTrainer(env, options); } } } diff --git a/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineTrainer.cs b/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineTrainer.cs index 84687b3ed9..ad41e60301 100644 --- a/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/FactorizationMachine/FactorizationMachineTrainer.cs @@ -15,12 +15,12 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(FieldAwareFactorizationMachineBinaryClassificationTrainer.Summary, typeof(FieldAwareFactorizationMachineBinaryClassificationTrainer), - typeof(FieldAwareFactorizationMachineBinaryClassificationTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer) } - , FieldAwareFactorizationMachineBinaryClassificationTrainer.UserName, FieldAwareFactorizationMachineBinaryClassificationTrainer.LoadName, - FieldAwareFactorizationMachineBinaryClassificationTrainer.ShortName, DocName = "trainer/FactorizationMachine.md")] +[assembly: LoadableClass(FieldAwareFactorizationMachineTrainer.Summary, typeof(FieldAwareFactorizationMachineTrainer), + typeof(FieldAwareFactorizationMachineTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer) } + , FieldAwareFactorizationMachineTrainer.UserName, FieldAwareFactorizationMachineTrainer.LoadName, + FieldAwareFactorizationMachineTrainer.ShortName, DocName = "trainer/FactorizationMachine.md")] -[assembly: LoadableClass(typeof(void), typeof(FieldAwareFactorizationMachineBinaryClassificationTrainer), null, typeof(SignatureEntryPointModule), FieldAwareFactorizationMachineBinaryClassificationTrainer.LoadName)] +[assembly: LoadableClass(typeof(void), typeof(FieldAwareFactorizationMachineTrainer), null, typeof(SignatureEntryPointModule), FieldAwareFactorizationMachineTrainer.LoadName)] namespace Microsoft.ML.Trainers { @@ -32,7 +32,7 @@ namespace Microsoft.ML.Trainers [3] https://github.com/wschin/fast-ffm/blob/master/fast-ffm.pdf */ /// - public sealed class FieldAwareFactorizationMachineBinaryClassificationTrainer : ITrainer, + public sealed class FieldAwareFactorizationMachineTrainer : ITrainer, IEstimator { internal const string Summary = "Train a field-aware factorization machine for binary classification"; @@ -151,12 +151,12 @@ public sealed class Options : TrainerInputBaseWithWeight private float _radius; /// - /// Initializes a new instance of through the class. + /// Initializes a new instance of through the class. /// /// The private instance of . /// An instance of the legacy to apply advanced parameters to the algorithm. [BestFriend] - internal FieldAwareFactorizationMachineBinaryClassificationTrainer(IHostEnvironment env, Options options) + internal FieldAwareFactorizationMachineTrainer(IHostEnvironment env, Options options) { Contracts.CheckValue(env, nameof(env)); _host = env.Register(LoadName); @@ -178,14 +178,14 @@ internal FieldAwareFactorizationMachineBinaryClassificationTrainer(IHostEnvironm } /// - /// Initializes a new instance of . + /// Initializes a new instance of . /// /// The private instance of . /// The name of column hosting the features. The i-th element stores feature column of the i-th field. /// The name of the label column. /// The name of the weight column (optional). [BestFriend] - internal FieldAwareFactorizationMachineBinaryClassificationTrainer(IHostEnvironment env, + internal FieldAwareFactorizationMachineTrainer(IHostEnvironment env, string[] featureColumnNames, string labelColumnName = DefaultColumnNames.Label, string exampleWeightColumnName = null) @@ -514,12 +514,12 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro var host = env.Register("Train a field-aware factorization machine"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return TrainerEntryPointsUtils.Train(host, input, () => new FieldAwareFactorizationMachineBinaryClassificationTrainer(host, input), + return TrainerEntryPointsUtils.Train(host, input, () => new FieldAwareFactorizationMachineTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } /// - /// Continues the training of a using an already trained and/or validation data, + /// Continues the training of a using an already trained and/or validation data, /// and returns a . /// public FieldAwareFactorizationMachinePredictionTransformer Fit(IDataView trainData, diff --git a/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/LogisticRegression.cs b/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/LogisticRegression.cs index 405048f3b1..5674aa1fe6 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/LogisticRegression.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/LogisticRegression.cs @@ -16,21 +16,21 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(LogisticRegression.Summary, typeof(LogisticRegression), typeof(LogisticRegression.Options), +[assembly: LoadableClass(LogisticRegressionBinaryClassificationTrainer.Summary, typeof(LogisticRegressionBinaryClassificationTrainer), typeof(LogisticRegressionBinaryClassificationTrainer.Options), new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - LogisticRegression.UserNameValue, - LogisticRegression.LoadNameValue, - LogisticRegression.ShortName, + LogisticRegressionBinaryClassificationTrainer.UserNameValue, + LogisticRegressionBinaryClassificationTrainer.LoadNameValue, + LogisticRegressionBinaryClassificationTrainer.ShortName, "logisticregressionwrapper")] -[assembly: LoadableClass(typeof(void), typeof(LogisticRegression), null, typeof(SignatureEntryPointModule), LogisticRegression.LoadNameValue)] +[assembly: LoadableClass(typeof(void), typeof(LogisticRegressionBinaryClassificationTrainer), null, typeof(SignatureEntryPointModule), LogisticRegressionBinaryClassificationTrainer.LoadNameValue)] namespace Microsoft.ML.Trainers { /// /// - public sealed partial class LogisticRegression : LbfgsTrainerBase>, CalibratedModelParametersBase> { @@ -55,7 +55,7 @@ public sealed class Options : OptionsBase /// /// The instance of that computes the std of the training statistics, at the end of training. /// The calculations are not part of Microsoft.ML package, due to the size of MKL. - /// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize . + /// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize . /// to the implementation in the Microsoft.ML.Mkl.Components package. /// public ComputeLogisticRegressionStandardDeviation ComputeStandardDeviation; @@ -65,7 +65,7 @@ public sealed class Options : OptionsBase private LinearModelStatistics _stats; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The environment to use. /// The name of the label column. @@ -74,9 +74,9 @@ public sealed class Options : OptionsBase /// Enforce non-negative weights. /// Weight of L1 regularizer term. /// Weight of L2 regularizer term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. - internal LogisticRegression(IHostEnvironment env, + internal LogisticRegressionBinaryClassificationTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, @@ -96,9 +96,9 @@ internal LogisticRegression(IHostEnvironment env, } /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal LogisticRegression(IHostEnvironment env, Options options) + internal LogisticRegressionBinaryClassificationTrainer(IHostEnvironment env, Options options) : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName)) { _posWeight = 0; @@ -128,7 +128,7 @@ private protected override BinaryPredictionTransformer new BinaryPredictionTransformer>(Host, model, trainSchema, FeatureColumn.Name); /// - /// Continues the training of a using an already trained and returns + /// Continues the training of a using an already trained and returns /// a . /// public BinaryPredictionTransformer> Fit(IDataView trainData, LinearModelParameters modelParameters) @@ -421,7 +421,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new LogisticRegression(host, input), + () => new LogisticRegressionBinaryClassificationTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } @@ -440,7 +440,7 @@ public abstract class ComputeLogisticRegressionStandardDeviation /// Computes the standard deviation matrix of each of the non-zero training weights, needed to calculate further the standard deviation, /// p-value and z-Score. /// The calculations are not part of Microsoft.ML package, due to the size of MKL. - /// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize + /// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize /// to the implementation in the Microsoft.ML.Mkl.Components package. /// Due to the existence of regularization, an approximation is used to compute the variances of the trained linear coefficients. /// diff --git a/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs b/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs index e4175dee8b..9b30d907a7 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs @@ -20,12 +20,12 @@ using Microsoft.ML.Trainers; using Newtonsoft.Json.Linq; -[assembly: LoadableClass(typeof(MulticlassLogisticRegression), typeof(MulticlassLogisticRegression.Options), +[assembly: LoadableClass(typeof(LogisticRegressionMulticlassClassificationTrainer), typeof(LogisticRegressionMulticlassClassificationTrainer.Options), new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, - MulticlassLogisticRegression.UserNameValue, - MulticlassLogisticRegression.LoadNameValue, + LogisticRegressionMulticlassClassificationTrainer.UserNameValue, + LogisticRegressionMulticlassClassificationTrainer.LoadNameValue, "MulticlassLogisticRegressionPredictorNew", - MulticlassLogisticRegression.ShortName, + LogisticRegressionMulticlassClassificationTrainer.ShortName, "multilr")] [assembly: LoadableClass(typeof(MulticlassLogisticRegressionModelParameters), null, typeof(SignatureLoadModel), @@ -36,7 +36,7 @@ namespace Microsoft.ML.Trainers { /// /// - public sealed class MulticlassLogisticRegression : LbfgsTrainerBase, MulticlassLogisticRegressionModelParameters> { internal const string LoadNameValue = "MultiClassLogisticRegression"; @@ -72,7 +72,7 @@ public sealed class Options : OptionsBase private protected override int ClassCount => _numClasses; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The environment to use. /// The name of the label column. @@ -81,9 +81,9 @@ public sealed class Options : OptionsBase /// Enforce non-negative weights. /// Weight of L1 regularizer term. /// Weight of L2 regularizer term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. - internal MulticlassLogisticRegression(IHostEnvironment env, + internal LogisticRegressionMulticlassClassificationTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, @@ -101,9 +101,9 @@ internal MulticlassLogisticRegression(IHostEnvironment env, } /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal MulticlassLogisticRegression(IHostEnvironment env, Options options) + internal LogisticRegressionMulticlassClassificationTrainer(IHostEnvironment env, Options options) : base(env, options, TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) { ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStatistics; @@ -329,7 +329,7 @@ private protected override MulticlassPredictionTransformer new MulticlassPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name, LabelColumn.Name); /// - /// Continues the training of a using an already trained and returns + /// Continues the training of a using an already trained and returns /// a . /// public MulticlassPredictionTransformer Fit(IDataView trainData, MulticlassLogisticRegressionModelParameters modelParameters) @@ -430,7 +430,7 @@ internal MulticlassLogisticRegressionModelParameters(IHostEnvironment env, in VB /// /// Initializes a new instance of the class. - /// This constructor is called by to create the predictor. + /// This constructor is called by to create the predictor. /// /// The host environment. /// The array of weights vectors. It should contain weights. @@ -780,7 +780,7 @@ private void Calibrate(Span dst) /// void ICanSaveInTextFormat.SaveAsText(TextWriter writer, RoleMappedSchema schema) { - writer.WriteLine(nameof(MulticlassLogisticRegression) + " bias and non-zero weights"); + writer.WriteLine(nameof(LogisticRegressionMulticlassClassificationTrainer) + " bias and non-zero weights"); foreach (var namedValues in ((ICanGetSummaryInKeyValuePairs)this).GetSummaryInKeyValuePairs(schema)) { @@ -1005,21 +1005,21 @@ DataViewRow ICanGetSummaryAsIRow.GetStatsIRowOrNull(RoleMappedSchema schema) /// /// A component to train a logistic regression model. /// - public partial class LogisticRegression + public partial class LogisticRegressionBinaryClassificationTrainer { [TlcModule.EntryPoint(Name = "Trainers.LogisticRegressionClassifier", Desc = Summary, - UserName = MulticlassLogisticRegression.UserNameValue, - ShortName = MulticlassLogisticRegression.ShortName)] - internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, MulticlassLogisticRegression.Options input) + UserName = LogisticRegressionMulticlassClassificationTrainer.UserNameValue, + ShortName = LogisticRegressionMulticlassClassificationTrainer.ShortName)] + internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, LogisticRegressionMulticlassClassificationTrainer.Options input) { Contracts.CheckValue(env, nameof(env)); var host = env.Register("TrainLRMultiClass"); host.CheckValue(input, nameof(input)); EntryPointUtils.CheckInputArgs(host, input); - return TrainerEntryPointsUtils.Train(host, input, - () => new MulticlassLogisticRegression(host, input), + return TrainerEntryPointsUtils.Train(host, input, + () => new LogisticRegressionMulticlassClassificationTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs index 5a36405abf..70c1d39287 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MetaMulticlassTrainer.cs @@ -15,7 +15,7 @@ namespace Microsoft.ML.Trainers { using TScalarTrainer = ITrainerEstimator>, IPredictorProducing>; - public abstract class MetaMulticlassTrainer : ITrainerEstimator, ITrainer + public abstract class MetaMulticlassClassificationTrainer : ITrainerEstimator, ITrainer where TTransformer : ISingleFeaturePredictionTransformer where TModel : class { @@ -53,7 +53,7 @@ internal abstract class OptionsBase public TrainerInfo Info { get; } /// - /// Initializes the from the class. + /// Initializes the from the class. /// /// The private instance of the . /// The legacy arguments class. @@ -61,7 +61,7 @@ internal abstract class OptionsBase /// The label column for the metalinear trainer and the binary trainer. /// The binary estimator. /// The calibrator. If a calibrator is not explicitly provided, it will default to - internal MetaMulticlassTrainer(IHostEnvironment env, OptionsBase options, string name, string labelColumn = null, + internal MetaMulticlassClassificationTrainer(IHostEnvironment env, OptionsBase options, string name, string labelColumn = null, TScalarTrainer singleEstimator = null, ICalibratorTrainer calibrator = null) { Host = Contracts.CheckRef(env, nameof(env)).Register(name); diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs index 0faacec7c3..d8bcc13bf3 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs @@ -14,20 +14,20 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(MultiClassNaiveBayesTrainer.Summary, typeof(MultiClassNaiveBayesTrainer), typeof(MultiClassNaiveBayesTrainer.Options), +[assembly: LoadableClass(NaiveBayesTrainer.Summary, typeof(NaiveBayesTrainer), typeof(NaiveBayesTrainer.Options), new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer) }, - MultiClassNaiveBayesTrainer.UserName, - MultiClassNaiveBayesTrainer.LoadName, - MultiClassNaiveBayesTrainer.ShortName, DocName = "trainer/NaiveBayes.md")] + 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(void), typeof(MultiClassNaiveBayesTrainer), null, typeof(SignatureEntryPointModule), MultiClassNaiveBayesTrainer.LoadName)] +[assembly: LoadableClass(typeof(void), typeof(NaiveBayesTrainer), null, typeof(SignatureEntryPointModule), NaiveBayesTrainer.LoadName)] namespace Microsoft.ML.Trainers { - public sealed class MultiClassNaiveBayesTrainer : TrainerEstimatorBase, MultiClassNaiveBayesModelParameters> + public sealed class NaiveBayesTrainer : TrainerEstimatorBase, MultiClassNaiveBayesModelParameters> { internal const string LoadName = "MultiClassNaiveBayes"; internal const string UserName = "Multiclass Naive Bayes"; @@ -50,12 +50,12 @@ internal sealed class Options : TrainerInputBaseWithLabel public override TrainerInfo Info => _info; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The environment to use. /// The name of the label column. /// The name of the feature column. - internal MultiClassNaiveBayesTrainer(IHostEnvironment env, + internal NaiveBayesTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadName), TrainerUtils.MakeR4VecFeature(featureColumn), @@ -66,9 +66,9 @@ internal MultiClassNaiveBayesTrainer(IHostEnvironment env, } /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal MultiClassNaiveBayesTrainer(IHostEnvironment env, Options options) + internal NaiveBayesTrainer(IHostEnvironment env, Options options) : base(Contracts.CheckRef(env, nameof(env)).Register(LoadName), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName), TrainerUtils.MakeU4ScalarColumn(options.LabelColumnName)) { @@ -176,7 +176,7 @@ internal static CommonOutputs.MulticlassClassificationOutput TrainMultiClassNaiv EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new MultiClassNaiveBayesTrainer(host, input), + () => new NaiveBayesTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } } diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs index 9fb2dd563a..fd743440d1 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/OneVersusAllTrainer.cs @@ -39,7 +39,7 @@ namespace Microsoft.ML.Trainers using TScalarPredictor = IPredictorProducing; using TScalarTrainer = ITrainerEstimator>, IPredictorProducing>; - public sealed class OneVersusAllTrainer : MetaMulticlassTrainer, OneVersusAllModelParameters> + public sealed class OneVersusAllTrainer : MetaMulticlassClassificationTrainer, OneVersusAllModelParameters> { internal const string LoadNameValue = "OVA"; internal const string UserNameValue = "One-vs-All"; diff --git a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs index 6fb27a5edd..26ea2b463c 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/MultiClass/PairwiseCouplingTrainer.cs @@ -52,7 +52,7 @@ namespace Microsoft.ML.Trainers /// L-BFGS history for all classes *simultaneously*, rather than just one-by-one /// as would be needed for a one-versus-all classification model. /// - public sealed class PairwiseCouplingTrainer : MetaMulticlassTrainer, PairwiseCouplingModelParameters> + public sealed class PairwiseCouplingTrainer : MetaMulticlassClassificationTrainer, PairwiseCouplingModelParameters> { internal const string LoadNameValue = "PKPD"; internal const string UserNameValue = "Pairwise coupling (PKPD)"; diff --git a/src/Microsoft.ML.StandardTrainers/Standard/PoissonRegression/PoissonRegression.cs b/src/Microsoft.ML.StandardTrainers/Standard/PoissonRegression/PoissonRegression.cs index 63d455a58e..a4f464418a 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/PoissonRegression/PoissonRegression.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/PoissonRegression/PoissonRegression.cs @@ -13,20 +13,20 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(PoissonRegression.Summary, typeof(PoissonRegression), typeof(PoissonRegression.Options), +[assembly: LoadableClass(PoissonRegressionTrainer.Summary, typeof(PoissonRegressionTrainer), typeof(PoissonRegressionTrainer.Options), new[] { typeof(SignatureRegressorTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - PoissonRegression.UserNameValue, - PoissonRegression.LoadNameValue, + PoissonRegressionTrainer.UserNameValue, + PoissonRegressionTrainer.LoadNameValue, "PoissonRegressionNew", "Poisson", - PoissonRegression.ShortName)] + PoissonRegressionTrainer.ShortName)] -[assembly: LoadableClass(typeof(void), typeof(PoissonRegression), null, typeof(SignatureEntryPointModule), PoissonRegression.LoadNameValue)] +[assembly: LoadableClass(typeof(void), typeof(PoissonRegressionTrainer), null, typeof(SignatureEntryPointModule), PoissonRegressionTrainer.LoadNameValue)] namespace Microsoft.ML.Trainers { /// - public sealed class PoissonRegression : LbfgsTrainerBase, PoissonRegressionModelParameters> + public sealed class PoissonRegressionTrainer : LbfgsTrainerBase, PoissonRegressionModelParameters> { internal const string LoadNameValue = "PoissonRegression"; internal const string UserNameValue = "Poisson Regression"; @@ -40,7 +40,7 @@ public sealed class Options : OptionsBase private Double _lossNormalizer; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The environment to use. /// The name of the label column. @@ -49,9 +49,9 @@ public sealed class Options : OptionsBase /// Weight of L1 regularizer term. /// Weight of L2 regularizer term. /// Threshold for optimizer convergence. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Enforce non-negative weights. - internal PoissonRegression(IHostEnvironment env, + internal PoissonRegressionTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, @@ -68,9 +68,9 @@ internal PoissonRegression(IHostEnvironment env, } /// - /// Initializes a new instance of + /// Initializes a new instance of /// - internal PoissonRegression(IHostEnvironment env, Options options) + internal PoissonRegressionTrainer(IHostEnvironment env, Options options) : base(env, options, TrainerUtils.MakeR4ScalarColumn(options.LabelColumnName)) { } @@ -95,7 +95,7 @@ private protected override RegressionPredictionTransformer new RegressionPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Continues the training of a using an already trained and returns + /// Continues the training of a using an already trained and returns /// a . /// public RegressionPredictionTransformer Fit(IDataView trainData, LinearModelParameters linearModel) @@ -184,7 +184,7 @@ internal static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment EntryPointUtils.CheckInputArgs(host, input); return TrainerEntryPointsUtils.Train(host, input, - () => new PoissonRegression(host, input), + () => new PoissonRegressionTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName)); } diff --git a/src/Microsoft.ML.StandardTrainers/Standard/SdcaBinary.cs b/src/Microsoft.ML.StandardTrainers/Standard/SdcaBinary.cs index fd4da0336d..6c333e2364 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/SdcaBinary.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/SdcaBinary.cs @@ -1426,8 +1426,8 @@ public void Add(Double summand) /// /// SDCA is a general training algorithm for (generalized) linear models such as support vector machine, linear regression, logistic regression, /// and so on. SDCA binary classification trainer family includes several sealed members: - /// (1) supports general loss functions and returns . - /// (2) essentially trains a regularized logistic regression model. Because logistic regression + /// (1) supports general loss functions and returns . + /// (2) essentially trains a regularized logistic regression model. Because logistic regression /// naturally provide probability output, this generated model's type is . /// where is and is . /// @@ -1547,17 +1547,17 @@ private protected override BinaryPredictionTransformer MakeTra /// linear function to a . /// /// - public sealed class SdcaBinaryTrainer : + public sealed class SdcaCalibratedBinaryClassificationTrainer : SdcaBinaryTrainerBase> { /// - /// Options for the . + /// Options for the . /// public sealed class Options : BinaryOptionsBase { } - internal SdcaBinaryTrainer(IHostEnvironment env, + internal SdcaCalibratedBinaryClassificationTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string weightColumnName = null, @@ -1568,7 +1568,7 @@ internal SdcaBinaryTrainer(IHostEnvironment env, { } - internal SdcaBinaryTrainer(IHostEnvironment env, Options options) + internal SdcaCalibratedBinaryClassificationTrainer(IHostEnvironment env, Options options) : base(env, options, new LogLoss()) { } @@ -1611,10 +1611,10 @@ private protected override SchemaShape.Column[] ComputeSdcaBinaryClassifierSchem /// The for training a binary logistic regression classification model using the stochastic dual coordinate ascent method. /// /// - public sealed class SdcaNonCalibratedBinaryTrainer : SdcaBinaryTrainerBase + public sealed class SdcaNonCalibratedBinaryClassificationTrainer : SdcaBinaryTrainerBase { /// - /// Options for the . + /// Options for the . /// public sealed class Options : BinaryOptionsBase { @@ -1636,7 +1636,7 @@ public sealed class Options : BinaryOptionsBase public ISupportSdcaClassificationLoss LossFunction { get; set; } } - internal SdcaNonCalibratedBinaryTrainer(IHostEnvironment env, + internal SdcaNonCalibratedBinaryClassificationTrainer(IHostEnvironment env, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string weightColumnName = null, @@ -1648,7 +1648,7 @@ internal SdcaNonCalibratedBinaryTrainer(IHostEnvironment env, { } - internal SdcaNonCalibratedBinaryTrainer(IHostEnvironment env, Options options) + internal SdcaNonCalibratedBinaryClassificationTrainer(IHostEnvironment env, Options options) : base(env, options, options.LossFunction ?? options.LossFunctionFactory.CreateComponent(env)) { } @@ -1674,7 +1674,7 @@ private protected override SchemaShape.Column[] ComputeSdcaBinaryClassifierSchem } /// - /// Comparing with , + /// Comparing with , /// directly outputs a built from /// the learned weights and bias without calibration. /// @@ -1941,7 +1941,7 @@ private protected override BinaryPredictionTransformer MakeTransformer(T => new BinaryPredictionTransformer(Host, model, trainSchema, FeatureColumn.Name); /// - /// Continues the training of a using an already trained and returns a . + /// Continues the training of a using an already trained and returns a . /// public BinaryPredictionTransformer Fit(IDataView trainData, LinearModelParameters modelParameters) => TrainTransformer(trainData, initPredictor: modelParameters); @@ -2176,17 +2176,17 @@ private protected override void CheckLabel(RoleMappedData examples, out int weig /// that supports multi-threading without any locking. If the associated optimization problem is sparse, Hogwild SGD achieves a nearly optimal /// rate of convergence. For more details about Hogwild SGD, please refer to http://arxiv.org/pdf/1106.5730v2.pdf. /// - public sealed class SgdBinaryTrainer : + public sealed class SgdCalibratedTrainer : SgdBinaryTrainerBase> { /// - /// Options for the . + /// Options for the . /// public sealed class Options : OptionsBase { } - internal SgdBinaryTrainer(IHostEnvironment env, + internal SgdCalibratedTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weightColumn = null, @@ -2202,7 +2202,7 @@ internal SgdBinaryTrainer(IHostEnvironment env, /// /// The environment to use. /// Advanced arguments to the algorithm. - internal SgdBinaryTrainer(IHostEnvironment env, Options options) + internal SgdCalibratedTrainer(IHostEnvironment env, Options options) : base(env, options, loss: new LogLoss(), doCalibration: false) { } @@ -2236,10 +2236,10 @@ private protected override CalibratedModelParametersBase - /// can train a linear classification model by minimizing any loss function + /// can train a linear classification model by minimizing any loss function /// which implements . /// - public sealed class SgdNonCalibratedBinaryTrainer : + public sealed class SgdNonCalibratedTrainer : SgdBinaryTrainerBase { public sealed class Options : OptionsBase @@ -2251,7 +2251,7 @@ public sealed class Options : OptionsBase public IClassificationLoss Loss = new LogLoss(); } - internal SgdNonCalibratedBinaryTrainer(IHostEnvironment env, + internal SgdNonCalibratedTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weightColumn = null, @@ -2264,11 +2264,11 @@ internal SgdNonCalibratedBinaryTrainer(IHostEnvironment env, } /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The environment to use. /// Advanced arguments to the algorithm. - internal SgdNonCalibratedBinaryTrainer(IHostEnvironment env, Options options) + internal SgdNonCalibratedTrainer(IHostEnvironment env, Options options) : base(env, options, loss: options.Loss, doCalibration: false) { } diff --git a/src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs b/src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs index 9fa3992b52..5a2a36c944 100644 --- a/src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs +++ b/src/Microsoft.ML.StandardTrainers/Standard/SdcaMultiClass.cs @@ -17,11 +17,11 @@ using Microsoft.ML.Runtime; using Microsoft.ML.Trainers; -[assembly: LoadableClass(SdcaMultiClassTrainer.Summary, typeof(SdcaMultiClassTrainer), typeof(SdcaMultiClassTrainer.Options), +[assembly: LoadableClass(SdcaMulticlassClassificationTrainer.Summary, typeof(SdcaMulticlassClassificationTrainer), typeof(SdcaMulticlassClassificationTrainer.Options), new[] { typeof(SignatureMultiClassClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) }, - SdcaMultiClassTrainer.UserNameValue, - SdcaMultiClassTrainer.LoadNameValue, - SdcaMultiClassTrainer.ShortName)] + SdcaMulticlassClassificationTrainer.UserNameValue, + SdcaMulticlassClassificationTrainer.LoadNameValue, + SdcaMulticlassClassificationTrainer.ShortName)] namespace Microsoft.ML.Trainers { @@ -29,7 +29,7 @@ namespace Microsoft.ML.Trainers /// The for training a multiclass logistic regression classification model using the stochastic dual coordinate ascent method. /// /// - public sealed class SdcaMultiClassTrainer : SdcaTrainerBase, MulticlassLogisticRegressionModelParameters> + public sealed class SdcaMulticlassClassificationTrainer : SdcaTrainerBase, MulticlassLogisticRegressionModelParameters> { internal const string LoadNameValue = "SDCAMC"; internal const string UserNameValue = "Fast Linear Multi-class Classification (SA-SDCA)"; @@ -37,7 +37,7 @@ public sealed class SdcaMultiClassTrainer : SdcaTrainerBase - /// Options for the . + /// Options for the . /// public sealed class Options : OptionsBase { @@ -64,7 +64,7 @@ public sealed class Options : OptionsBase private protected override PredictionKind PredictionKind => PredictionKind.MultiClassClassification; /// - /// Initializes a new instance of + /// Initializes a new instance of /// /// The environment to use. /// The label, or dependent variable. @@ -74,7 +74,7 @@ public sealed class Options : OptionsBase /// The L2 regularization hyperparameter. /// The L1 regularization hyperparameter. Higher values will tend to lead to more sparse model. /// The maximum number of passes to perform over the data. - internal SdcaMultiClassTrainer(IHostEnvironment env, + internal SdcaMulticlassClassificationTrainer(IHostEnvironment env, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, @@ -91,7 +91,7 @@ internal SdcaMultiClassTrainer(IHostEnvironment env, Loss = _loss; } - internal SdcaMultiClassTrainer(IHostEnvironment env, Options options, + internal SdcaMulticlassClassificationTrainer(IHostEnvironment env, Options options, string featureColumn, string labelColumn, string weightColumn = null) : base(env, options, TrainerUtils.MakeU4ScalarColumn(labelColumn), TrainerUtils.MakeR4ScalarWeightColumn(weightColumn)) { @@ -102,7 +102,7 @@ internal SdcaMultiClassTrainer(IHostEnvironment env, Options options, Loss = _loss; } - internal SdcaMultiClassTrainer(IHostEnvironment env, Options options) + internal SdcaMulticlassClassificationTrainer(IHostEnvironment env, Options options) : this(env, options, options.FeatureColumnName, options.LabelColumnName) { } @@ -449,18 +449,18 @@ private protected override MulticlassPredictionTransformer(host, input, - () => new SdcaMultiClassTrainer(host, input), + return TrainerEntryPointsUtils.Train(host, input, + () => new SdcaMulticlassClassificationTrainer(host, input), () => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName)); } } diff --git a/src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs b/src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs index 4be5a0ada9..2c7019bbfd 100644 --- a/src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs +++ b/src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs @@ -9,7 +9,7 @@ namespace Microsoft.ML { - using LROptions = LogisticRegression.Options; + using LROptions = LogisticRegressionBinaryClassificationTrainer.Options; /// /// TrainerEstimator extension methods. @@ -17,7 +17,8 @@ namespace Microsoft.ML public static class StandardTrainersCatalog { /// - /// Predict a target using a linear classification model trained with . + /// Predict a target using a linear classification model trained with . + /// Stochastic gradient descent (SGD) is an iterative algorithm that optimizes a differentiable objective function. /// /// The binary classification catalog trainer object. /// The name of the label column, or dependent variable. @@ -33,22 +34,23 @@ public static class StandardTrainersCatalog /// ]]> /// /// - public static SgdBinaryTrainer StochasticGradientDescent(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static SgdCalibratedTrainer SgdCalibrated(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, - int numberOfIterations = SgdBinaryTrainer.Options.Defaults.NumberOfIterations, - double initialLearningRate = SgdBinaryTrainer.Options.Defaults.InitialLearningRate, - float l2Regularization = SgdBinaryTrainer.Options.Defaults.L2Regularization) + int numberOfIterations = SgdCalibratedTrainer.Options.Defaults.NumberOfIterations, + double initialLearningRate = SgdCalibratedTrainer.Options.Defaults.InitialLearningRate, + float l2Regularization = SgdCalibratedTrainer.Options.Defaults.L2Regularization) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new SgdBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, + return new SgdCalibratedTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, initialLearningRate, l2Regularization); } /// - /// Predict a target using a linear classification model trained with and advanced options. + /// Predict a target using a linear classification model trained with and advanced options. + /// Stochastic gradient descent (SGD) is an iterative algorithm that optimizes a differentiable objective function. /// /// The binary classification catalog trainer object. /// Trainer options. @@ -59,18 +61,19 @@ public static SgdBinaryTrainer StochasticGradientDescent(this BinaryClassificati /// ]]> /// /// - public static SgdBinaryTrainer StochasticGradientDescent(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - SgdBinaryTrainer.Options options) + public static SgdCalibratedTrainer SgdCalibrated(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + SgdCalibratedTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new SgdBinaryTrainer(env, options); + return new SgdCalibratedTrainer(env, options); } /// - /// Predict a target using a linear classification model trained with . + /// Predict a target using a linear classification model trained with . + /// Stochastic gradient descent (SGD) is an iterative algorithm that optimizes a differentiable objective function. /// /// The binary classification catalog trainer object. /// The name of the label column, or dependent variable. @@ -87,23 +90,24 @@ public static SgdBinaryTrainer StochasticGradientDescent(this BinaryClassificati /// ]]> /// /// - public static SgdNonCalibratedBinaryTrainer StochasticGradientDescentNonCalibrated(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static SgdNonCalibratedTrainer SgdNonCalibrated(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, IClassificationLoss loss = null, - int numberOfIterations = SgdNonCalibratedBinaryTrainer.Options.Defaults.NumberOfIterations, - double initialLearningRate = SgdNonCalibratedBinaryTrainer.Options.Defaults.InitialLearningRate, - float l2Regularization = SgdNonCalibratedBinaryTrainer.Options.Defaults.L2Regularization) + int numberOfIterations = SgdNonCalibratedTrainer.Options.Defaults.NumberOfIterations, + double initialLearningRate = SgdNonCalibratedTrainer.Options.Defaults.InitialLearningRate, + float l2Regularization = SgdNonCalibratedTrainer.Options.Defaults.L2Regularization) { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new SgdNonCalibratedBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, + return new SgdNonCalibratedTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, numberOfIterations, initialLearningRate, l2Regularization, loss); } /// - /// Predict a target using a linear classification model trained with and advanced options. + /// Predict a target using a linear classification model trained with and advanced options. + /// Stochastic gradient descent (SGD) is an iterative algorithm that optimizes a differentiable objective function. /// /// The binary classification catalog trainer object. /// Trainer options. @@ -114,14 +118,14 @@ public static SgdNonCalibratedBinaryTrainer StochasticGradientDescentNonCalibrat /// ]]> /// /// - public static SgdNonCalibratedBinaryTrainer StochasticGradientDescentNonCalibrated(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - SgdNonCalibratedBinaryTrainer.Options options) + public static SgdNonCalibratedTrainer SgdNonCalibrated(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + SgdNonCalibratedTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new SgdNonCalibratedBinaryTrainer(env, options); + return new SgdNonCalibratedTrainer(env, options); } /// @@ -141,7 +145,7 @@ public static SgdNonCalibratedBinaryTrainer StochasticGradientDescentNonCalibrat /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscent.cs)] /// ]]> /// - public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this RegressionCatalog.RegressionTrainers catalog, + public static SdcaRegressionTrainer Sdca(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -166,7 +170,7 @@ public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this Regressi /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/StochasticDualCoordinateAscentWithOptions.cs)] /// ]]> /// - public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this RegressionCatalog.RegressionTrainers catalog, + public static SdcaRegressionTrainer Sdca(this RegressionCatalog.RegressionTrainers catalog, SdcaRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); @@ -177,7 +181,7 @@ public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this Regressi } /// - /// Predict a target using a linear classification model trained with . + /// Predict a target using a linear classification model trained with . /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -192,7 +196,7 @@ public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this Regressi /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscent.cs)] /// ]]> /// - public static SdcaBinaryTrainer StochasticDualCoordinateAscent( + public static SdcaCalibratedBinaryClassificationTrainer SdcaCalibrated( this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, @@ -203,11 +207,11 @@ public static SdcaBinaryTrainer StochasticDualCoordinateAscent( { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new SdcaBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l2Regularization, l1Threshold, maximumNumberOfIterations); + return new SdcaCalibratedBinaryClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l2Regularization, l1Threshold, maximumNumberOfIterations); } /// - /// Predict a target using a linear classification model trained with and advanced options. + /// Predict a target using a linear classification model trained with and advanced options. /// /// The binary classification catalog trainer object. /// Trainer options. @@ -217,19 +221,19 @@ public static SdcaBinaryTrainer StochasticDualCoordinateAscent( /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentWithOptions.cs)] /// ]]> /// - public static SdcaBinaryTrainer StochasticDualCoordinateAscent( + public static SdcaCalibratedBinaryClassificationTrainer SdcaCalibrated( this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - SdcaBinaryTrainer.Options options) + SdcaCalibratedBinaryClassificationTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new SdcaBinaryTrainer(env, options); + return new SdcaCalibratedBinaryClassificationTrainer(env, options); } /// - /// Predict a target using a linear classification model trained with . + /// Predict a target using a linear classification model trained with . /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -245,7 +249,7 @@ public static SdcaBinaryTrainer StochasticDualCoordinateAscent( /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscentNonCalibrated.cs)] /// ]]> /// - public static SdcaNonCalibratedBinaryTrainer StochasticDualCoordinateAscentNonCalibrated( + public static SdcaNonCalibratedBinaryClassificationTrainer SdcaNonCalibrated( this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, @@ -257,27 +261,27 @@ public static SdcaNonCalibratedBinaryTrainer StochasticDualCoordinateAscentNonCa { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new SdcaNonCalibratedBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations); + return new SdcaNonCalibratedBinaryClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations); } /// - /// Predict a target using a linear classification model trained with and advanced options. + /// Predict a target using a linear classification model trained with and advanced options. /// /// The binary classification catalog trainer object. /// Trainer options. - public static SdcaNonCalibratedBinaryTrainer StochasticDualCoordinateAscentNonCalibrated( + public static SdcaNonCalibratedBinaryClassificationTrainer SdcaNonCalibrated( this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, - SdcaNonCalibratedBinaryTrainer.Options options) + SdcaNonCalibratedBinaryClassificationTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new SdcaNonCalibratedBinaryTrainer(env, options); + return new SdcaNonCalibratedBinaryClassificationTrainer(env, options); } /// - /// Predict a target using a linear multiclass classification model trained with . + /// Predict a target using a linear multiclass classification model trained with . /// /// The multiclass classification catalog trainer object. /// The name of the label column. @@ -293,7 +297,7 @@ public static SdcaNonCalibratedBinaryTrainer StochasticDualCoordinateAscentNonCa /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscent.cs)] /// ]]> /// - public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + public static SdcaMulticlassClassificationTrainer Sdca(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -304,11 +308,11 @@ public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this Multicla { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new SdcaMultiClassTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations); + return new SdcaMulticlassClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations); } /// - /// Predict a target using a linear multiclass classification model trained with and advanced options. + /// Predict a target using a linear multiclass classification model trained with and advanced options. /// /// The multiclass classification catalog trainer object. /// Trainer options. @@ -318,14 +322,14 @@ public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this Multicla /// [!code-csharp[SDCA](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/StochasticDualCoordinateAscentWithOptions.cs)] /// ]]> /// - public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, - SdcaMultiClassTrainer.Options options) + public static SdcaMulticlassClassificationTrainer Sdca(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + SdcaMulticlassClassificationTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new SdcaMultiClassTrainer(env, options); + return new SdcaMulticlassClassificationTrainer(env, options); } /// @@ -444,7 +448,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression } /// - /// Predict a target using a linear binary classification model trained with the trainer. + /// Predict a target using a linear binary classification model trained with the trainer. /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -453,7 +457,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression /// Enforce non-negative weights. /// Weight of L1 regularization term. /// Weight of L2 regularization term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. /// /// @@ -462,7 +466,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression /// ]]> /// /// - public static LogisticRegression LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static LogisticRegressionBinaryClassificationTrainer LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -474,25 +478,25 @@ public static LogisticRegression LogisticRegression(this BinaryClassificationCat { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new LogisticRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); + return new LogisticRegressionBinaryClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); } /// - /// Predict a target using a linear binary classification model trained with the trainer. + /// Predict a target using a linear binary classification model trained with the trainer. /// /// The binary classification catalog trainer object. /// Advanced arguments to the algorithm. - public static LogisticRegression LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, LROptions options) + public static LogisticRegressionBinaryClassificationTrainer LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, LROptions options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new LogisticRegression(env, options); + return new LogisticRegressionBinaryClassificationTrainer(env, options); } /// - /// Predict a target using a linear regression model trained with the trainer. + /// Predict a target using a linear regression model trained with the trainer. /// /// The regression catalog trainer object. /// The name of the label column. @@ -501,9 +505,9 @@ public static LogisticRegression LogisticRegression(this BinaryClassificationCat /// Weight of L1 regularization term. /// Weight of L2 regularization term. /// Threshold for optimizer convergence. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Enforce non-negative weights. - public static PoissonRegression PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, + public static PoissonRegressionTrainer PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -515,25 +519,25 @@ public static PoissonRegression PoissonRegression(this RegressionCatalog.Regress { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new PoissonRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); + return new PoissonRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); } /// - /// Predict a target using a linear regression model trained with the trainer. + /// Predict a target using a linear regression model trained with the trainer. /// /// The regression catalog trainer object. /// Advanced arguments to the algorithm. - public static PoissonRegression PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, PoissonRegression.Options options) + public static PoissonRegressionTrainer PoissonRegression(this RegressionCatalog.RegressionTrainers catalog, PoissonRegressionTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new PoissonRegression(env, options); + return new PoissonRegressionTrainer(env, options); } /// - /// 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 . /// The name of the label column. @@ -542,9 +546,9 @@ public static PoissonRegression PoissonRegression(this RegressionCatalog.Regress /// Enforce non-negative weights. /// Weight of L1 regularization term. /// Weight of L2 regularization term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. - public static MulticlassLogisticRegression LogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + public static LogisticRegressionMulticlassClassificationTrainer LogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -556,37 +560,37 @@ public static MulticlassLogisticRegression LogisticRegression(this MulticlassCla { Contracts.CheckValue(catalog, nameof(catalog)); var env = CatalogUtils.GetEnvironment(catalog); - return new MulticlassLogisticRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); + return new LogisticRegressionMulticlassClassificationTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); } /// - /// 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 . /// Advanced arguments to the algorithm. - public static MulticlassLogisticRegression LogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, - MulticlassLogisticRegression.Options options) + public static LogisticRegressionMulticlassClassificationTrainer LogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + LogisticRegressionMulticlassClassificationTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(catalog); - return new MulticlassLogisticRegression(env, options); + return new LogisticRegressionMulticlassClassificationTrainer(env, options); } /// - /// Predicts a target using a linear multiclass classification model trained with the . - /// The trains a multiclass Naive Bayes predictor that supports binary feature values. + /// Predicts a target using a linear multiclass classification model trained with the . + /// The trains a multiclass Naive Bayes predictor that supports binary feature values. /// /// The . /// The name of the label column. /// The name of the feature column. - public static MultiClassNaiveBayesTrainer NaiveBayes(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, + public static NaiveBayesTrainer NaiveBayes(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features) { Contracts.CheckValue(catalog, nameof(catalog)); - return new MultiClassNaiveBayesTrainer(CatalogUtils.GetEnvironment(catalog), labelColumnName, featureColumnName); + return new NaiveBayesTrainer(CatalogUtils.GetEnvironment(catalog), labelColumnName, featureColumnName); } /// @@ -681,7 +685,7 @@ public static PairwiseCouplingTrainer PairwiseCoupling(this MulticlassCl /// /// /// - /// The idea behind support vector machines, is to map instances into a high dimensional space + /// The idea behind support vector machines (SVM), is to map instances into a high dimensional space /// in which the two classes are linearly separable, i.e., there exists a hyperplane such that all the positive examples are on one side of it, /// and all the negative examples are on the other. /// @@ -695,7 +699,7 @@ public static PairwiseCouplingTrainer PairwiseCoupling(this MulticlassCl /// The name of the feature column. /// The name of the example weight column (optional). /// The number of training iteraitons. - public static LinearSvmTrainer LinearSupportVectorMachines(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static LinearSvmTrainer LinearSvm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, @@ -710,7 +714,7 @@ public static LinearSvmTrainer LinearSupportVectorMachines(this BinaryClassifica /// /// /// - /// The idea behind support vector machines, is to map instances into a high dimensional space + /// The idea behind support vector machines (SVM), is to map instances into a high dimensional space /// in which the two classes are linearly separable, i.e., there exists a hyperplane such that all the positive examples are on one side of it, /// and all the negative examples are on the other. /// @@ -721,7 +725,7 @@ public static LinearSvmTrainer LinearSupportVectorMachines(this BinaryClassifica /// /// The . /// Advanced arguments to the algorithm. - public static LinearSvmTrainer LinearSupportVectorMachines(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, + public static LinearSvmTrainer LinearSvm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, LinearSvmTrainer.Options options) { Contracts.CheckValue(catalog, nameof(catalog)); diff --git a/src/Microsoft.ML.StaticPipe/FactorizationMachineStatic.cs b/src/Microsoft.ML.StaticPipe/FactorizationMachineStatic.cs index 007bf5d67a..69d726907f 100644 --- a/src/Microsoft.ML.StaticPipe/FactorizationMachineStatic.cs +++ b/src/Microsoft.ML.StaticPipe/FactorizationMachineStatic.cs @@ -40,7 +40,7 @@ public static (Scalar score, Scalar predictedLabel) FieldAwareFacto var rec = new CustomReconciler((env, labelCol, featureCols) => { - var trainer = new FieldAwareFactorizationMachineBinaryClassificationTrainer(env, featureCols, labelCol); + var trainer = new FieldAwareFactorizationMachineTrainer(env, featureCols, labelCol); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -66,7 +66,7 @@ public static (Scalar score, Scalar predictedLabel) FieldAwareFacto /// The predicted output. public static (Scalar score, Scalar predictedLabel) FieldAwareFactorizationMachine(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, Scalar label, Vector[] features, - FieldAwareFactorizationMachineBinaryClassificationTrainer.Options options, + FieldAwareFactorizationMachineTrainer.Options options, Action onFit = null) { Contracts.CheckValue(label, nameof(label)); @@ -77,7 +77,7 @@ public static (Scalar score, Scalar predictedLabel) FieldAwareFacto var rec = new CustomReconciler((env, labelCol, featureCols) => { - var trainer = new FieldAwareFactorizationMachineBinaryClassificationTrainer(env, options); + var trainer = new FieldAwareFactorizationMachineTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); else diff --git a/src/Microsoft.ML.StaticPipe/KMeansStatic.cs b/src/Microsoft.ML.StaticPipe/KMeansStatic.cs index 17b5ecd247..8918102717 100644 --- a/src/Microsoft.ML.StaticPipe/KMeansStatic.cs +++ b/src/Microsoft.ML.StaticPipe/KMeansStatic.cs @@ -9,7 +9,7 @@ namespace Microsoft.ML.StaticPipe { /// - /// The trainer context extensions for the . + /// The trainer context extensions for the . /// public static class KMeansClusteringExtensions { @@ -28,7 +28,7 @@ public static class KMeansClusteringExtensions /// The predicted output. public static (Vector score, Key predictedLabel) KMeans(this ClusteringCatalog.ClusteringTrainers catalog, Vector features, Scalar weights = null, - int clustersCount = KMeansPlusPlusTrainer.Defaults.NumberOfClusters, + int clustersCount = KMeansTrainer.Defaults.NumberOfClusters, Action onFit = null) { Contracts.CheckValue(features, nameof(features)); @@ -39,14 +39,14 @@ public static (Vector score, Key predictedLabel) KMeans(this Cluste var rec = new TrainerEstimatorReconciler.Clustering( (env, featuresName, weightsName) => { - var options = new KMeansPlusPlusTrainer.Options + var options = new KMeansTrainer.Options { FeatureColumnName = featuresName, NumberOfClusters = clustersCount, ExampleWeightColumnName = weightsName }; - var trainer = new KMeansPlusPlusTrainer(env, options); + var trainer = new KMeansTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -72,7 +72,7 @@ public static (Vector score, Key predictedLabel) KMeans(this Cluste /// The predicted output. public static (Vector score, Key predictedLabel) KMeans(this ClusteringCatalog.ClusteringTrainers catalog, Vector features, Scalar weights, - KMeansPlusPlusTrainer.Options options, + KMeansTrainer.Options options, Action onFit = null) { Contracts.CheckValueOrNull(onFit); @@ -84,7 +84,7 @@ public static (Vector score, Key predictedLabel) KMeans(this Cluste options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new KMeansPlusPlusTrainer(env, options); + var trainer = new KMeansTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); diff --git a/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs b/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs index 96be5260d2..9dee1abcd2 100644 --- a/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs +++ b/src/Microsoft.ML.StaticPipe/LbfgsStatic.cs @@ -9,7 +9,7 @@ namespace Microsoft.ML.StaticPipe { - using Options = LogisticRegression.Options; + using Options = LogisticRegressionBinaryClassificationTrainer.Options; /// /// Binary Classification trainer estimators. @@ -17,7 +17,7 @@ namespace Microsoft.ML.StaticPipe public static class LbfgsBinaryClassificationStaticExtensions { /// - /// Predict a target using a linear binary classification model trained with the trainer. + /// Predict a target using a linear binary classification model trained with the trainer. /// /// The binary classification catalog trainer object. /// The label, or dependent variable. @@ -26,7 +26,7 @@ public static class LbfgsBinaryClassificationStaticExtensions /// Enforce non-negative weights. /// Weight of L1 regularization term. /// Weight of L2 regularization term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. /// A delegate that is called every time the /// method is called on the @@ -50,7 +50,7 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new LogisticRegression(env, labelName, featuresName, weightsName, + var trainer = new LogisticRegressionBinaryClassificationTrainer(env, labelName, featuresName, weightsName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); if (onFit != null) @@ -63,7 +63,7 @@ public static (Scalar score, Scalar probability, Scalar pred } /// - /// Predict a target using a linear binary classification model trained with the trainer. + /// Predict a target using a linear binary classification model trained with the trainer. /// /// The binary classification catalog trainer object. /// The label, or dependent variable. @@ -95,7 +95,7 @@ public static (Scalar score, Scalar probability, Scalar pred options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new LogisticRegression(env, options); + var trainer = new LogisticRegressionBinaryClassificationTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -113,7 +113,7 @@ public static (Scalar score, Scalar probability, Scalar pred public static class LbfgsRegressionExtensions { /// - /// Predict a target using a linear regression model trained with the trainer. + /// Predict a target using a linear regression model trained with the trainer. /// /// The regression catalog trainer object. /// The label, or dependent variable. @@ -122,7 +122,7 @@ public static class LbfgsRegressionExtensions /// Enforce non-negative weights. /// Weight of L1 regularization term. /// Weight of L2 regularization term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. /// A delegate that is called every time the /// method is called on the @@ -146,7 +146,7 @@ public static Scalar PoissonRegression(this RegressionCatalog.RegressionT var rec = new TrainerEstimatorReconciler.Regression( (env, labelName, featuresName, weightsName) => { - var trainer = new PoissonRegression(env, labelName, featuresName, weightsName, + var trainer = new PoissonRegressionTrainer(env, labelName, featuresName, weightsName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); if (onFit != null) @@ -159,7 +159,7 @@ public static Scalar PoissonRegression(this RegressionCatalog.RegressionT } /// - /// Predict a target using a linear regression model trained with the trainer. + /// Predict a target using a linear regression model trained with the trainer. /// /// The regression catalog trainer object. /// The label, or dependent variable. @@ -176,7 +176,7 @@ public static Scalar PoissonRegression(this RegressionCatalog.RegressionT Scalar label, Vector features, Scalar weights, - PoissonRegression.Options options, + PoissonRegressionTrainer.Options options, Action onFit = null) { Contracts.CheckValue(label, nameof(label)); @@ -191,7 +191,7 @@ public static Scalar PoissonRegression(this RegressionCatalog.RegressionT options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new PoissonRegression(env, options); + var trainer = new PoissonRegressionTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -209,7 +209,7 @@ public static Scalar PoissonRegression(this RegressionCatalog.RegressionT public static class LbfgsMulticlassExtensions { /// - /// 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. @@ -218,7 +218,7 @@ public static class LbfgsMulticlassExtensions /// Enforce non-negative weights. /// Weight of L1 regularization term. /// Weight of L2 regularization term. - /// Memory size for . Low=faster, less accurate. + /// Memory size for . Low=faster, less accurate. /// Threshold for optimizer convergence. /// A delegate that is called every time the /// method is called on the @@ -243,7 +243,7 @@ public static (Vector score, Key predictedLabel) var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new MulticlassLogisticRegression(env, labelName, featuresName, weightsName, + var trainer = new LogisticRegressionMulticlassClassificationTrainer(env, labelName, featuresName, weightsName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity); if (onFit != null) @@ -255,7 +255,7 @@ public static (Vector score, Key predictedLabel) } /// - /// 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. @@ -273,7 +273,7 @@ public static (Vector score, Key predictedLabel) Key label, Vector features, Scalar weights, - MulticlassLogisticRegression.Options options, + LogisticRegressionMulticlassClassificationTrainer.Options options, Action onFit = null) { Contracts.CheckValue(label, nameof(label)); @@ -288,7 +288,7 @@ public static (Vector score, Key predictedLabel) options.FeatureColumnName = featuresName; options.ExampleWeightColumnName = weightsName; - var trainer = new MulticlassLogisticRegression(env, options); + var trainer = new LogisticRegressionMulticlassClassificationTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); diff --git a/src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs b/src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs index fa602f4859..f01124156e 100644 --- a/src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs +++ b/src/Microsoft.ML.StaticPipe/MultiClassNaiveBayesStatic.cs @@ -38,7 +38,7 @@ public static (Vector score, Key predictedLabel) var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new MultiClassNaiveBayesTrainer(env, labelName, featuresName); + var trainer = new NaiveBayesTrainer(env, labelName, featuresName); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); diff --git a/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs index 2da753c331..af35f93554 100644 --- a/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/SdcaStaticExtensions.cs @@ -154,7 +154,7 @@ public static (Scalar score, Scalar probability, Scalar pred var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new SdcaBinaryTrainer(env, labelName, featuresName, weightsName, l2Regularization, l1Threshold, numberOfIterations); + var trainer = new SdcaCalibratedBinaryClassificationTrainer(env, labelName, featuresName, weightsName, l2Regularization, l1Threshold, numberOfIterations); if (onFit != null) { return trainer.WithOnFitDelegate(trans => @@ -192,7 +192,7 @@ public static (Scalar score, Scalar probability, Scalar pred public static (Scalar score, Scalar probability, Scalar predictedLabel) Sdca( this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, Scalar label, Vector features, Scalar weights, - SdcaBinaryTrainer.Options options, + SdcaCalibratedBinaryClassificationTrainer.Options options, Action> onFit = null) { Contracts.CheckValue(label, nameof(label)); @@ -207,7 +207,7 @@ public static (Scalar score, Scalar probability, Scalar pred options.LabelColumnName = labelName; options.FeatureColumnName = featuresName; - var trainer = new SdcaBinaryTrainer(env, options); + var trainer = new SdcaCalibratedBinaryClassificationTrainer(env, options); if (onFit != null) { return trainer.WithOnFitDelegate(trans => @@ -263,7 +263,7 @@ public static (Scalar score, Scalar predictedLabel) SdcaNonCalibrat var rec = new TrainerEstimatorReconciler.BinaryClassifierNoCalibration( (env, labelName, featuresName, weightsName) => { - var trainer = new SdcaNonCalibratedBinaryTrainer(env, labelName, featuresName, weightsName, loss, l2Regularization, l1Threshold, numberOfIterations); + var trainer = new SdcaNonCalibratedBinaryClassificationTrainer(env, labelName, featuresName, weightsName, loss, l2Regularization, l1Threshold, numberOfIterations); if (onFit != null) { return trainer.WithOnFitDelegate(trans => @@ -299,7 +299,7 @@ public static (Scalar score, Scalar predictedLabel) SdcaNonCalibrat this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, Scalar label, Vector features, Scalar weights, ISupportSdcaClassificationLoss loss, - SdcaNonCalibratedBinaryTrainer.Options options, + SdcaNonCalibratedBinaryClassificationTrainer.Options options, Action onFit = null) { Contracts.CheckValue(label, nameof(label)); @@ -314,7 +314,7 @@ public static (Scalar score, Scalar predictedLabel) SdcaNonCalibrat options.FeatureColumnName = featuresName; options.LabelColumnName = labelName; - var trainer = new SdcaNonCalibratedBinaryTrainer(env, options); + var trainer = new SdcaNonCalibratedBinaryClassificationTrainer(env, options); if (onFit != null) { return trainer.WithOnFitDelegate(trans => @@ -368,7 +368,7 @@ public static (Vector score, Key predictedLabel) Sdca( var rec = new TrainerEstimatorReconciler.MulticlassClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new SdcaMultiClassTrainer(env, labelName, featuresName, weightsName, loss, l2Regularization, l1Threshold, numberOfIterations); + var trainer = new SdcaMulticlassClassificationTrainer(env, labelName, featuresName, weightsName, loss, l2Regularization, l1Threshold, numberOfIterations); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); return trainer; @@ -396,7 +396,7 @@ public static (Vector score, Key predictedLabel) Sdca( Key label, Vector features, Scalar weights, - SdcaMultiClassTrainer.Options options, + SdcaMulticlassClassificationTrainer.Options options, Action onFit = null) { Contracts.CheckValue(label, nameof(label)); @@ -411,7 +411,7 @@ public static (Vector score, Key predictedLabel) Sdca( options.LabelColumnName = labelName; options.FeatureColumnName = featuresName; - var trainer = new SdcaMultiClassTrainer(env, options); + var trainer = new SdcaMulticlassClassificationTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); return trainer; diff --git a/src/Microsoft.ML.StaticPipe/SgdStatic.cs b/src/Microsoft.ML.StaticPipe/SgdStatic.cs index e2da102afe..3765238597 100644 --- a/src/Microsoft.ML.StaticPipe/SgdStatic.cs +++ b/src/Microsoft.ML.StaticPipe/SgdStatic.cs @@ -14,7 +14,7 @@ namespace Microsoft.ML.StaticPipe public static class SgdStaticExtensions { /// - /// Predict a target using logistic regression trained with the trainer. + /// Predict a target using logistic regression trained with the trainer. /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -34,15 +34,15 @@ public static (Scalar score, Scalar probability, Scalar pred Scalar label, Vector features, Scalar weights = null, - int numberOfIterations = SgdBinaryTrainer.Options.Defaults.NumberOfIterations, - double initialLearningRate = SgdBinaryTrainer.Options.Defaults.InitialLearningRate, - float l2Regularization = SgdBinaryTrainer.Options.Defaults.L2Regularization, + int numberOfIterations = SgdCalibratedTrainer.Options.Defaults.NumberOfIterations, + double initialLearningRate = SgdCalibratedTrainer.Options.Defaults.InitialLearningRate, + float l2Regularization = SgdCalibratedTrainer.Options.Defaults.L2Regularization, Action> onFit = null) { var rec = new TrainerEstimatorReconciler.BinaryClassifier( (env, labelName, featuresName, weightsName) => { - var trainer = new SgdBinaryTrainer(env, labelName, featuresName, weightsName, numberOfIterations, initialLearningRate, l2Regularization); + var trainer = new SgdCalibratedTrainer(env, labelName, featuresName, weightsName, numberOfIterations, initialLearningRate, l2Regularization); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -54,7 +54,7 @@ public static (Scalar score, Scalar probability, Scalar pred } /// - /// Predict a target using logistic regression trained with the trainer. + /// Predict a target using logistic regression trained with the trainer. /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -72,7 +72,7 @@ public static (Scalar score, Scalar probability, Scalar pred Scalar label, Vector features, Scalar weights, - SgdBinaryTrainer.Options options, + SgdCalibratedTrainer.Options options, Action> onFit = null) { var rec = new TrainerEstimatorReconciler.BinaryClassifier( @@ -82,7 +82,7 @@ public static (Scalar score, Scalar probability, Scalar pred options.LabelColumnName = labelName; options.ExampleWeightColumnName = weightsName; - var trainer = new SgdBinaryTrainer(env, options); + var trainer = new SgdCalibratedTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); @@ -94,7 +94,7 @@ public static (Scalar score, Scalar probability, Scalar pred } /// - /// Predict a target using a linear classification model trained with the trainer. + /// Predict a target using a linear classification model trained with the trainer. /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -115,16 +115,16 @@ public static (Scalar score, Scalar predictedLabel) StochasticGradi Scalar label, Vector features, Scalar weights = null, - int numberOfIterations = SgdNonCalibratedBinaryTrainer.Options.Defaults.NumberOfIterations, - double initialLearningRate = SgdNonCalibratedBinaryTrainer.Options.Defaults.InitialLearningRate, - float l2Regularization = SgdNonCalibratedBinaryTrainer.Options.Defaults.L2Regularization, + int numberOfIterations = SgdNonCalibratedTrainer.Options.Defaults.NumberOfIterations, + double initialLearningRate = SgdNonCalibratedTrainer.Options.Defaults.InitialLearningRate, + float l2Regularization = SgdNonCalibratedTrainer.Options.Defaults.L2Regularization, IClassificationLoss loss = null, Action onFit = null) { var rec = new TrainerEstimatorReconciler.BinaryClassifierNoCalibration( (env, labelName, featuresName, weightsName) => { - var trainer = new SgdNonCalibratedBinaryTrainer(env, labelName, featuresName, weightsName, + var trainer = new SgdNonCalibratedTrainer(env, labelName, featuresName, weightsName, numberOfIterations, initialLearningRate, l2Regularization, loss); if (onFit != null) @@ -137,7 +137,7 @@ public static (Scalar score, Scalar predictedLabel) StochasticGradi } /// - /// Predict a target using a linear classification model trained with the trainer. + /// Predict a target using a linear classification model trained with the trainer. /// /// The binary classification catalog trainer object. /// The name of the label column. @@ -155,7 +155,7 @@ public static (Scalar score, Scalar predictedLabel) StochasticGradi Scalar label, Vector features, Scalar weights, - SgdNonCalibratedBinaryTrainer.Options options, + SgdNonCalibratedTrainer.Options options, Action onFit = null) { var rec = new TrainerEstimatorReconciler.BinaryClassifierNoCalibration( @@ -165,7 +165,7 @@ public static (Scalar score, Scalar predictedLabel) StochasticGradi options.LabelColumnName = labelName; options.ExampleWeightColumnName = weightsName; - var trainer = new SgdNonCalibratedBinaryTrainer(env, options); + var trainer = new SgdNonCalibratedTrainer(env, options); if (onFit != null) return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); diff --git a/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs b/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs index 61cffff813..498eabfba3 100644 --- a/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs +++ b/src/Microsoft.ML.Sweeper/Algorithms/SmacSweeper.cs @@ -134,8 +134,8 @@ private FastForestRegressionModelParameters FitModel(IEnumerable pre { // Set relevant random forest arguments. // Train random forest. - var trainer = new FastForestRegression(_host, - new FastForestRegression.Options + var trainer = new FastForestRegressionTrainer(_host, + new FastForestRegressionTrainer.Options { FeatureFraction = _args.SplitRatio, NumberOfTrees = _args.NumOfTrees, diff --git a/test/BaselineOutput/Common/Command/CommandTrainMlrWithStats-summary.txt b/test/BaselineOutput/Common/Command/CommandTrainMlrWithStats-summary.txt index f8e0fadf34..18e66a6f8a 100644 --- a/test/BaselineOutput/Common/Command/CommandTrainMlrWithStats-summary.txt +++ b/test/BaselineOutput/Common/Command/CommandTrainMlrWithStats-summary.txt @@ -1,4 +1,4 @@ -MulticlassLogisticRegression bias and non-zero weights +LogisticRegressionMulticlassClassificationTrainer bias and non-zero weights Iris-setosa+(Bias) 2.265129 Iris-versicolor+(Bias) 0.7695086 Iris-virginica+(Bias) -3.034663 diff --git a/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv b/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv index 3bc0eba707..37833e10e3 100644 --- a/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv +++ b/test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv @@ -43,33 +43,33 @@ Trainers.AveragedPerceptronBinaryClassifier Averaged Perceptron Binary Classifie 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.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.FastForestClassification+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.FastForestRegression+Options 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 Trainers.FastTreeBinaryClassifier Uses a logit-boost boosted tree learner to perform binary classification. Microsoft.ML.Trainers.FastTree.FastTree TrainBinary Microsoft.ML.Trainers.FastTree.FastTreeBinaryClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Trainers.FastTreeRanker Trains gradient boosted decision trees to the LambdaRank quasi-gradient. Microsoft.ML.Trainers.FastTree.FastTree TrainRanking Microsoft.ML.Trainers.FastTree.FastTreeRankingTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RankingOutput Trainers.FastTreeRegressor Trains gradient boosted decision trees to fit target values using least-squares. Microsoft.ML.Trainers.FastTree.FastTree TrainRegression Microsoft.ML.Trainers.FastTree.FastTreeRegressionTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput Trainers.FastTreeTweedieRegressor Trains gradient boosted decision trees to fit target values using a Tweedie loss function. This learner is a generalization of Poisson, compound Poisson, and gamma regression. Microsoft.ML.Trainers.FastTree.FastTree TrainTweedieRegression Microsoft.ML.Trainers.FastTree.FastTreeTweedieTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput -Trainers.FieldAwareFactorizationMachineBinaryClassifier Train a field-aware factorization machine for binary classification Microsoft.ML.Trainers.FieldAwareFactorizationMachineBinaryClassificationTrainer TrainBinary Microsoft.ML.Trainers.FieldAwareFactorizationMachineBinaryClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -Trainers.GeneralizedAdditiveModelBinaryClassifier 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 TrainBinary Microsoft.ML.Trainers.FastTree.BinaryClassificationGamTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput -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.RegressionGamTrainer+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.KMeansPlusPlusTrainer TrainKMeans Microsoft.ML.Trainers.KMeansPlusPlusTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+ClusteringOutput +Trainers.FieldAwareFactorizationMachineBinaryClassifier Train a field-aware factorization machine for binary classification Microsoft.ML.Trainers.FieldAwareFactorizationMachineTrainer TrainBinary Microsoft.ML.Trainers.FieldAwareFactorizationMachineTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput +Trainers.GeneralizedAdditiveModelBinaryClassifier 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 TrainBinary Microsoft.ML.Trainers.FastTree.GamBinaryClassificationTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput +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.LightGBM.LightGbm TrainBinary Microsoft.ML.LightGBM.Options Microsoft.ML.EntryPoints.CommonOutputs+BinaryClassificationOutput Trainers.LightGbmClassifier Train a LightGBM multi class model. Microsoft.ML.LightGBM.LightGbm TrainMultiClass Microsoft.ML.LightGBM.Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput Trainers.LightGbmRanker Train a LightGBM ranking model. Microsoft.ML.LightGBM.LightGbm TrainRanking Microsoft.ML.LightGBM.Options Microsoft.ML.EntryPoints.CommonOutputs+RankingOutput Trainers.LightGbmRegressor LightGBM Regression Microsoft.ML.LightGBM.LightGbm TrainRegression Microsoft.ML.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.LogisticRegression TrainBinary Microsoft.ML.Trainers.LogisticRegression+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.LogisticRegression TrainMultiClass Microsoft.ML.Trainers.MulticlassLogisticRegression+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput -Trainers.NaiveBayesClassifier Train a MultiClassNaiveBayesTrainer. Microsoft.ML.Trainers.MultiClassNaiveBayesTrainer TrainMultiClassNaiveBayesTrainer Microsoft.ML.Trainers.MultiClassNaiveBayesTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+MulticlassClassificationOutput +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.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.OrdinaryLeastSquaresRegressionTrainer TrainRegression Microsoft.ML.Trainers.OrdinaryLeastSquaresRegressionTrainer+Options Microsoft.ML.EntryPoints.CommonOutputs+RegressionOutput -Trainers.PcaAnomalyDetector Train an PCA Anomaly model. Microsoft.ML.Trainers.RandomizedPrincipalComponentAnalyzer TrainPcaAnomaly Microsoft.ML.Trainers.RandomizedPrincipalComponentAnalyzer+Options Microsoft.ML.EntryPoints.CommonOutputs+AnomalyDetectionOutput -Trainers.PoissonRegressor Train an Poisson regression model. Microsoft.ML.Trainers.PoissonRegression TrainRegression Microsoft.ML.Trainers.PoissonRegression+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.SdcaMultiClassTrainer+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.SymbolicStochasticGradientDescentClassificationTrainer TrainSymSgd Microsoft.ML.Trainers.SymbolicStochasticGradientDescentClassificationTrainer+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 Transforms.ApproximateBootstrapSampler Approximate bootstrap sampling. Microsoft.ML.Transforms.BootstrapSample GetSample Microsoft.ML.Transforms.BootstrapSamplingTransformer+Options Microsoft.ML.EntryPoints.CommonOutputs+TransformOutput Transforms.BinaryPredictionScoreColumnsRenamer For binary prediction, it renames the PredictedLabel and Score columns to include the name of the positive class. Microsoft.ML.EntryPoints.ScoreModel RenameBinaryPredictionScoreColumns Microsoft.ML.EntryPoints.ScoreModel+RenameBinaryPredictionScoreColumnsInput Microsoft.ML.EntryPoints.CommonOutputs+TransformOutput Transforms.BinNormalizer The values are assigned into equidensity bins and a value is mapped to its bin_number/number_of_bins. Microsoft.ML.Data.Normalize Bin Microsoft.ML.Transforms.NormalizeTransform+BinArguments Microsoft.ML.EntryPoints.CommonOutputs+TransformOutput diff --git a/test/BaselineOutput/Common/EntryPoints/core_manifest.json b/test/BaselineOutput/Common/EntryPoints/core_manifest.json index 5c8414eca2..379b9085f5 100644 --- a/test/BaselineOutput/Common/EntryPoints/core_manifest.json +++ b/test/BaselineOutput/Common/EntryPoints/core_manifest.json @@ -11376,7 +11376,7 @@ { "Name": "Sigmoid", "Type": "Float", - "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryTrainer, LightGbmMulticlassTrainer and in LightGbmRankingTrainer.", + "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryClassificationTrainer, LightGbmMulticlassClassificationTrainer and in LightGbmRankingTrainer.", "Aliases": [ "sigmoid" ], @@ -11879,7 +11879,7 @@ { "Name": "Sigmoid", "Type": "Float", - "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryTrainer, LightGbmMulticlassTrainer and in LightGbmRankingTrainer.", + "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryClassificationTrainer, LightGbmMulticlassClassificationTrainer and in LightGbmRankingTrainer.", "Aliases": [ "sigmoid" ], @@ -12382,7 +12382,7 @@ { "Name": "Sigmoid", "Type": "Float", - "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryTrainer, LightGbmMulticlassTrainer and in LightGbmRankingTrainer.", + "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryClassificationTrainer, LightGbmMulticlassClassificationTrainer and in LightGbmRankingTrainer.", "Aliases": [ "sigmoid" ], @@ -12885,7 +12885,7 @@ { "Name": "Sigmoid", "Type": "Float", - "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryTrainer, LightGbmMulticlassTrainer and in LightGbmRankingTrainer.", + "Desc": "Parameter for the sigmoid function. Used only in LightGbmBinaryClassificationTrainer, LightGbmMulticlassClassificationTrainer and in LightGbmRankingTrainer.", "Aliases": [ "sigmoid" ], diff --git a/test/Microsoft.ML.Benchmarks/KMeansAndLogisticRegressionBench.cs b/test/Microsoft.ML.Benchmarks/KMeansAndLogisticRegressionBench.cs index a1b11352d5..7f568adca6 100644 --- a/test/Microsoft.ML.Benchmarks/KMeansAndLogisticRegressionBench.cs +++ b/test/Microsoft.ML.Benchmarks/KMeansAndLogisticRegressionBench.cs @@ -40,7 +40,7 @@ public CalibratedModelParametersBase(); + var environment = EnvironmentFactory.CreateRankingEnvironment(); cmd.ExecuteMamlCommand(environment); } } diff --git a/test/Microsoft.ML.Benchmarks/PredictionEngineBench.cs b/test/Microsoft.ML.Benchmarks/PredictionEngineBench.cs index 49a07fc085..c873226741 100644 --- a/test/Microsoft.ML.Benchmarks/PredictionEngineBench.cs +++ b/test/Microsoft.ML.Benchmarks/PredictionEngineBench.cs @@ -58,8 +58,8 @@ public void SetupIrisPipeline() var pipeline = new ColumnConcatenatingEstimator(env, "Features", new[] { "SepalLength", "SepalWidth", "PetalLength", "PetalWidth" }) .Append(env.Transforms.Conversion.MapValueToKey("Label")) - .Append(env.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, })); + .Append(env.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, })); var model = pipeline.Fit(data); @@ -93,8 +93,8 @@ public void SetupSentimentPipeline() IDataView data = loader.Load(_sentimentDataPath); var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText") - .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, })); + .Append(mlContext.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, })); var model = pipeline.Fit(data); @@ -127,8 +127,8 @@ public void SetupBreastCancerPipeline() IDataView data = loader.Load(_breastCancerDataPath); - var pipeline = env.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, }); + var pipeline = env.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, }); var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs b/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs index d8929e926d..5420df3d83 100644 --- a/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs +++ b/test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs @@ -72,7 +72,7 @@ private TransformerChain(); + var environment = EnvironmentFactory.CreateClassificationEnvironment(); cmd.ExecuteMamlCommand(environment); } @@ -85,7 +85,7 @@ public void CV_Multiclass_WikiDetox_WordEmbeddings_SDCAMC() " xf=WordEmbeddingsTransform{col=FeaturesWordEmbedding:FeaturesText_TransformedText model=FastTextWikipedia300D}" + " xf=Concat{col=Features:FeaturesWordEmbedding,logged_in,ns}"; - var environment = EnvironmentFactory.CreateClassificationEnvironment(); + var environment = EnvironmentFactory.CreateClassificationEnvironment(); cmd.ExecuteMamlCommand(environment); } } diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index 546f48df6b..c72d88c628 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -134,7 +134,7 @@ public void EntryPointScoring() var dataView = GetBreastCancerDataviewWithTextColumns(); dataView = Env.CreateTransform("Term{col=F1}", dataView); var trainData = FeatureCombiner.PrepareFeatures(Env, new FeatureCombiner.FeatureCombinerInput() { Data = dataView, Features = new[] { "F1", "F2", "Rest" } }); - var lrModel = LogisticRegression.TrainBinary(Env, new LogisticRegression.Options { TrainingData = trainData.OutputData }).PredictorModel; + var lrModel = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = trainData.OutputData }).PredictorModel; var model = ModelOperations.CombineTwoModels(Env, new ModelOperations.SimplePredictorModelInput() { TransformModel = trainData.Model, PredictorModel = lrModel }).PredictorModel; var scored1 = ScoreModel.Score(Env, new ScoreModel.Input() { Data = dataView, PredictorModel = model }).ScoredData; @@ -327,7 +327,7 @@ public void EntryPointCatalogCheckDuplicateParams() Env.ComponentCatalog.RegisterAssembly(typeof(LightGbmBinaryModelParameters).Assembly); Env.ComponentCatalog.RegisterAssembly(typeof(TensorFlowTransformer).Assembly); Env.ComponentCatalog.RegisterAssembly(typeof(ImageLoadingTransformer).Assembly); - Env.ComponentCatalog.RegisterAssembly(typeof(SymbolicStochasticGradientDescentClassificationTrainer).Assembly); + Env.ComponentCatalog.RegisterAssembly(typeof(SymbolicSgdTrainer).Assembly); Env.ComponentCatalog.RegisterAssembly(typeof(SaveOnnxCommand).Assembly); Env.ComponentCatalog.RegisterAssembly(typeof(TimeSeriesProcessingEntryPoints).Assembly); Env.ComponentCatalog.RegisterAssembly(typeof(ParquetLoader).Assembly); @@ -364,12 +364,12 @@ public void EntryPointInputBuilderOptionals() { var catalog = Env.ComponentCatalog; - InputBuilder ib1 = new InputBuilder(Env, typeof(LogisticRegression.Options), catalog); + InputBuilder ib1 = new InputBuilder(Env, typeof(LogisticRegressionBinaryClassificationTrainer.Options), catalog); // Ensure that InputBuilder unwraps the Optional correctly. var weightType = ib1.GetFieldTypeOrNull("ExampleWeightColumnName"); Assert.True(weightType.Equals(typeof(string))); - var instance = ib1.GetInstance() as LogisticRegression.Options; + var instance = ib1.GetInstance() as LogisticRegressionBinaryClassificationTrainer.Options; Assert.True(instance.ExampleWeightColumnName == null); ib1.TrySetValue("ExampleWeightColumnName", "OtherWeight"); @@ -422,14 +422,14 @@ public void EntryPointCreateEnsemble() for (int i = 0; i < nModels; i++) { var data = splitOutput.TrainData[i]; - var lrInput = new LogisticRegression.Options + var lrInput = new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = data, L1Regularization = (Single)0.1 * i, L2Regularization = (Single)0.01 * (1 + i), NormalizeFeatures = NormalizeOption.No }; - predictorModels[i] = LogisticRegression.TrainBinary(Env, lrInput).PredictorModel; + predictorModels[i] = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, lrInput).PredictorModel; individualScores[i] = ScoreModel.Score(Env, new ScoreModel.Input { Data = splitOutput.TestData[nModels], PredictorModel = predictorModels[i] }) @@ -678,7 +678,7 @@ public void EntryPointCalibrate() var splitOutput = CVSplit.Split(Env, new CVSplit.Input { Data = dataView, NumFolds = 3 }); - var lrModel = LogisticRegression.TrainBinary(Env, new LogisticRegression.Options { TrainingData = splitOutput.TestData[0] }).PredictorModel; + var lrModel = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = splitOutput.TestData[0] }).PredictorModel; var calibratedLrModel = Calibrate.FixedPlatt(Env, new Calibrate.FixedPlattInput { Data = splitOutput.TestData[1], UncalibratedPredictorModel = lrModel }).PredictorModel; @@ -697,7 +697,7 @@ public void EntryPointCalibrate() calibratedLrModel = Calibrate.Pav(Env, input).PredictorModel; // This tests that the SchemaBindableCalibratedPredictor doesn't get confused if its sub-predictor is already calibrated. - var fastForest = new FastForestClassification(Env, "Label", "Features"); + var fastForest = new FastForestBinaryClassificationTrainer(Env, "Label", "Features"); var rmd = new RoleMappedData(splitOutput.TrainData[0], "Label", "Features"); var ffModel = new PredictorModelImpl(Env, rmd, splitOutput.TrainData[0], fastForest.Train(rmd)); var calibratedFfModel = Calibrate.Platt(Env, @@ -726,14 +726,14 @@ public void EntryPointPipelineEnsemble() data = new ColumnConcatenatingTransformer(Env, "Features", new[] { "Features1", "Features2" }).Transform(data); data = new ValueToKeyMappingEstimator(Env, "Label", "Label", sort: ValueToKeyMappingEstimator.SortOrder.Value).Fit(data).Transform(data); - var lrInput = new LogisticRegression.Options + var lrInput = new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = data, L1Regularization = (Single)0.1 * i, L2Regularization = (Single)0.01 * (1 + i), NormalizeFeatures = NormalizeOption.Yes }; - predictorModels[i] = LogisticRegression.TrainBinary(Env, lrInput).PredictorModel; + predictorModels[i] = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, lrInput).PredictorModel; var transformModel = new TransformModelImpl(Env, data, splitOutput.TrainData[i]); predictorModels[i] = ModelOperations.CombineTwoModels(Env, @@ -988,14 +988,14 @@ public void EntryPointPipelineEnsembleText() }, data); } - var lrInput = new LogisticRegression.Options + var lrInput = new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = data, L1Regularization = (Single)0.1 * i, L2Regularization = (Single)0.01 * (1 + i), NormalizeFeatures = NormalizeOption.Yes }; - predictorModels[i] = LogisticRegression.TrainBinary(Env, lrInput).PredictorModel; + predictorModels[i] = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, lrInput).PredictorModel; var transformModel = new TransformModelImpl(Env, data, splitOutput.TrainData[i]); predictorModels[i] = ModelOperations.CombineTwoModels(Env, @@ -1321,7 +1321,7 @@ public void EntryPointPipelineEnsembleGetSummary() data = new ColumnConcatenatingTransformer(Env, new ColumnConcatenatingTransformer.ColumnOptions("Features", i % 2 == 0 ? new[] { "Features", "Cat" } : new[] { "Cat", "Features" })).Transform(data); if (i % 2 == 0) { - var lrInput = new LogisticRegression.Options + var lrInput = new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = data, NormalizeFeatures = NormalizeOption.Yes, @@ -1329,7 +1329,7 @@ public void EntryPointPipelineEnsembleGetSummary() ShowTrainingStatistics = true, ComputeStandardDeviation = new ComputeLRTrainingStdThroughMkl() }; - predictorModels[i] = LogisticRegression.TrainBinary(Env, lrInput).PredictorModel; + predictorModels[i] = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, lrInput).PredictorModel; var transformModel = new TransformModelImpl(Env, data, splitOutput.TrainData[i]); predictorModels[i] = ModelOperations.CombineTwoModels(Env, @@ -3350,7 +3350,7 @@ public void EntryPointLinearPredictorSummary() InputFile = inputFile, }).Data; - var lrInput = new LogisticRegression.Options + var lrInput = new LogisticRegressionBinaryClassificationTrainer.Options { TrainingData = dataView, NormalizeFeatures = NormalizeOption.Yes, @@ -3358,16 +3358,16 @@ public void EntryPointLinearPredictorSummary() ShowTrainingStatistics = true, ComputeStandardDeviation = new ComputeLRTrainingStdThroughMkl() }; - var model = LogisticRegression.TrainBinary(Env, lrInput).PredictorModel; + var model = LogisticRegressionBinaryClassificationTrainer.TrainBinary(Env, lrInput).PredictorModel; - var mcLrInput = new MulticlassLogisticRegression.Options + var mcLrInput = new LogisticRegressionMulticlassClassificationTrainer.Options { TrainingData = dataView, NormalizeFeatures = NormalizeOption.Yes, NumberOfThreads = 1, ShowTrainingStatistics = true }; - var mcModel = LogisticRegression.TrainMultiClass(Env, mcLrInput).PredictorModel; + var mcModel = LogisticRegressionBinaryClassificationTrainer.TrainMultiClass(Env, mcLrInput).PredictorModel; var output = SummarizePredictor.Summarize(Env, new SummarizePredictor.Input() { PredictorModel = model }); @@ -3424,11 +3424,11 @@ public void EntryPointPcaPredictorSummary() InputFile = inputFile, }).Data; - var pcaInput = new RandomizedPrincipalComponentAnalyzer.Options + var pcaInput = new RandomizedPcaTrainer.Options { TrainingData = dataView, }; - var model = RandomizedPrincipalComponentAnalyzer.TrainPcaAnomaly(Env, pcaInput).PredictorModel; + var model = RandomizedPcaTrainer.TrainPcaAnomaly(Env, pcaInput).PredictorModel; var output = SummarizePredictor.Summarize(Env, new SummarizePredictor.Input() { PredictorModel = model }); diff --git a/test/Microsoft.ML.Functional.Tests/DataTransformation.cs b/test/Microsoft.ML.Functional.Tests/DataTransformation.cs index f24d62d5e9..fc16d312ef 100644 --- a/test/Microsoft.ML.Functional.Tests/DataTransformation.cs +++ b/test/Microsoft.ML.Functional.Tests/DataTransformation.cs @@ -144,8 +144,8 @@ void ExtensibilityModifyTextFeaturization() VectorNormalizer = TextFeaturizingEstimator.NormFunction.L1 }, "SentimentText") .AppendCacheCheckpoint(mlContext) - .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaBinaryTrainer.Options { NumberOfThreads = 1 })); + .Append(mlContext.BinaryClassification.Trainers.SdcaCalibrated( + new SdcaCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train the model. var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Functional.Tests/Evaluation.cs b/test/Microsoft.ML.Functional.Tests/Evaluation.cs index 841b2c1aa0..93d0a93b78 100644 --- a/test/Microsoft.ML.Functional.Tests/Evaluation.cs +++ b/test/Microsoft.ML.Functional.Tests/Evaluation.cs @@ -35,7 +35,7 @@ public void TrainAndEvaluateAnomalyDetection() .Load(GetDataPath(TestDatasets.mnistOneClass.testFilename)); // Create a training pipeline. - var pipeline = mlContext.AnomalyDetection.Trainers.AnalyzeRandomizedPrincipalComponents(); + var pipeline = mlContext.AnomalyDetection.Trainers.RandomizedPca(); // Train the model. var model = pipeline.Fit(trainData); @@ -64,8 +64,8 @@ public void TrainAndEvaluateBinaryClassification() // Create a training pipeline. var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(mlContext) - .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1 })); + .Append(mlContext.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train the model. var model = pipeline.Fit(data); @@ -94,7 +94,7 @@ public void TrainAndEvaluateBinaryClassificationWithCalibration() var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(mlContext) .Append(mlContext.BinaryClassification.Trainers.LogisticRegression( - new LogisticRegression.Options { NumberOfThreads = 1 })); + new LogisticRegressionBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train the model. var model = pipeline.Fit(data); @@ -122,7 +122,7 @@ public void TrainAndEvaluateClustering() // Create a training pipeline. var pipeline = mlContext.Transforms.Concatenate("Features", Iris.Features) .AppendCacheCheckpoint(mlContext) - .Append(mlContext.Clustering.Trainers.KMeans(new KMeansPlusPlusTrainer.Options { NumberOfThreads = 1 })); + .Append(mlContext.Clustering.Trainers.KMeans(new KMeansTrainer.Options { NumberOfThreads = 1 })); // Train the model. var model = pipeline.Fit(data); @@ -151,8 +151,8 @@ public void TrainAndEvaluateMulticlassClassification() var pipeline = mlContext.Transforms.Concatenate("Features", Iris.Features) .Append(mlContext.Transforms.Conversion.MapValueToKey("Label")) .AppendCacheCheckpoint(mlContext) - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { NumberOfThreads = 1})); + .Append(mlContext.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { NumberOfThreads = 1})); // Train the model. var model = pipeline.Fit(data); @@ -242,7 +242,7 @@ public void TrainAndEvaluateRegression() var data = mlContext.Data.LoadFromTextFile(GetDataPath(TestDatasets.housing.trainFilename), hasHeader: true); // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) - .Append(mlContext.Regression.Trainers.FastForest(new FastForestRegression.Options { NumberOfThreads = 1 })); + .Append(mlContext.Regression.Trainers.FastForest(new FastForestRegressionTrainer.Options { NumberOfThreads = 1 })); // Train the model. var model = pipeline.Fit(data); @@ -274,7 +274,7 @@ public void TrainAndEvaluateWithPrecisionRecallCurves() var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(mlContext) .Append(mlContext.BinaryClassification.Trainers.LogisticRegression( - new LogisticRegression.Options { NumberOfThreads = 1 })); + new LogisticRegressionBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train the model. var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Functional.Tests/Explainability.cs b/test/Microsoft.ML.Functional.Tests/Explainability.cs index b268bf468d..3cb4d08b60 100644 --- a/test/Microsoft.ML.Functional.Tests/Explainability.cs +++ b/test/Microsoft.ML.Functional.Tests/Explainability.cs @@ -34,7 +34,7 @@ public void GlobalFeatureImportanceWithPermutationFeatureImportance() // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.Regression.Trainers.Sdca()); // Fit the pipeline and transform the data. var model = pipeline.Fit(data); @@ -66,7 +66,7 @@ public void GlobalFeatureImportanceForLinearModelThroughWeights() // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.Regression.Trainers.Sdca()); // Fit the pipeline and transform the data. var model = pipeline.Fit(data); @@ -144,7 +144,7 @@ public void LocalFeatureImportanceForLinearModel() // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.Regression.Trainers.Sdca()); // Fit the pipeline and transform the data. var model = pipeline.Fit(data); @@ -256,7 +256,7 @@ public void LocalFeatureImportanceForGamModel() // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) - .Append(mlContext.Regression.Trainers.GeneralizedAdditiveModels(numberOfIterations: 2)); + .Append(mlContext.Regression.Trainers.Gam(numberOfIterations: 2)); // Fit the pipeline and transform the data. var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Functional.Tests/IntrospectiveTraining.cs b/test/Microsoft.ML.Functional.Tests/IntrospectiveTraining.cs index 933eab22e3..8298d55a27 100644 --- a/test/Microsoft.ML.Functional.Tests/IntrospectiveTraining.cs +++ b/test/Microsoft.ML.Functional.Tests/IntrospectiveTraining.cs @@ -38,7 +38,7 @@ public void InspectFastForestRegresionTrees() // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) .Append(mlContext.Regression.Trainers.FastForest( - new FastForestRegression.Options { NumberOfLeaves = 5, NumberOfTrees = 3, NumberOfThreads = 1 })); + new FastForestRegressionTrainer.Options { NumberOfLeaves = 5, NumberOfTrees = 3, NumberOfThreads = 1 })); // Fit the pipeline. var model = pipeline.Fit(data); @@ -142,8 +142,8 @@ void IntrospectGamShapeFunctions() // Compose the transformation. var pipeline = mlContext.Transforms.Concatenate("Features", Iris.Features) - .Append(mlContext.Regression.Trainers.GeneralizedAdditiveModels( - new RegressionGamTrainer.Options { NumberOfIterations = 100, NumberOfThreads = 1 })); + .Append(mlContext.Regression.Trainers.Gam( + new GamRegressionTrainer.Options { NumberOfIterations = 100, NumberOfThreads = 1 })); // Fit the pipeline. var model = pipeline.Fit(data); @@ -216,8 +216,8 @@ public void InpsectLinearModelParameters() // Create a training pipeline. var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(mlContext) - .Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1 })); + .Append(mlContext.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Fit the pipeline. var model = pipeline.Fit(data); @@ -421,9 +421,9 @@ private IEstimator>> StepTwo(MLContext mlContext) { return mlContext.Transforms.Conversion.MapValueToKey("Label") - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { + .Append(mlContext.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { MaximumNumberOfIterations = 10, NumberOfThreads = 1 })); } diff --git a/test/Microsoft.ML.Functional.Tests/Prediction.cs b/test/Microsoft.ML.Functional.Tests/Prediction.cs index b0d1fee62a..4605f953bd 100644 --- a/test/Microsoft.ML.Functional.Tests/Prediction.cs +++ b/test/Microsoft.ML.Functional.Tests/Prediction.cs @@ -32,7 +32,7 @@ public void ReconfigurablePrediction() "CrimesPerCapita", "PercentResidental", "PercentNonRetail", "CharlesRiver", "NitricOxides", "RoomsPerDwelling", "PercentPre40s", "EmploymentDistance", "HighwayDistance", "TaxRate", "TeacherRatio"}) .Append(mlContext.Transforms.CopyColumns("Label", "MedianHomeValue")) - .Append(mlContext.Regression.Trainers.OrdinaryLeastSquares()); + .Append(mlContext.Regression.Trainers.Ols()); var model = pipeline.Fit(split.TrainSet); diff --git a/test/Microsoft.ML.Functional.Tests/Validation.cs b/test/Microsoft.ML.Functional.Tests/Validation.cs index 86157e2626..0585b45476 100644 --- a/test/Microsoft.ML.Functional.Tests/Validation.cs +++ b/test/Microsoft.ML.Functional.Tests/Validation.cs @@ -37,7 +37,7 @@ void CrossValidation() // Create a pipeline to train on the housing data. var pipeline = mlContext.Transforms.Concatenate("Features", HousingRegression.Features) - .Append(mlContext.Regression.Trainers.OrdinaryLeastSquares()); + .Append(mlContext.Regression.Trainers.Ols()); // Compute the CV result. var cvResult = mlContext.Regression.CrossValidate(data, pipeline, numFolds: 5); diff --git a/test/Microsoft.ML.Predictor.Tests/TestIniModels.cs b/test/Microsoft.ML.Predictor.Tests/TestIniModels.cs index fc20c7b95c..8ef374d434 100644 --- a/test/Microsoft.ML.Predictor.Tests/TestIniModels.cs +++ b/test/Microsoft.ML.Predictor.Tests/TestIniModels.cs @@ -527,7 +527,7 @@ public void TestGamRegressionIni() }).Load(GetDataPath("breast-cancer.txt")); var pipeline = mlContext.Transforms.ReplaceMissingValues("Features") - .Append(mlContext.Regression.Trainers.GeneralizedAdditiveModels()); + .Append(mlContext.Regression.Trainers.Gam()); var model = pipeline.Fit(idv); var data = model.Transform(idv); @@ -566,7 +566,7 @@ public void TestGamBinaryClassificationIni() }).Load(GetDataPath("breast-cancer.txt")); var pipeline = mlContext.Transforms.ReplaceMissingValues("Features") - .Append(mlContext.BinaryClassification.Trainers.GeneralizedAdditiveModels()); + .Append(mlContext.BinaryClassification.Trainers.Gam()); var model = pipeline.Fit(idv); var data = model.Transform(idv); diff --git a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs index 61ddf638b1..cfa5d6557c 100644 --- a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs +++ b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs @@ -41,7 +41,7 @@ protected override void InitializeEnvironment(IHostEnvironment environment) base.InitializeEnvironment(environment); environment.ComponentCatalog.RegisterAssembly(typeof(LightGbmBinaryModelParameters).Assembly); - environment.ComponentCatalog.RegisterAssembly(typeof(SymbolicStochasticGradientDescentClassificationTrainer).Assembly); + environment.ComponentCatalog.RegisterAssembly(typeof(SymbolicSgdTrainer).Assembly); } /// @@ -740,7 +740,7 @@ public void TestEnsembleCombiner() TrainingData = dataView, NormalizeFeatures = NormalizeOption.No }).PredictorModel, - LogisticRegression.TrainBinary(ML, new LogisticRegression.Options() + LogisticRegressionBinaryClassificationTrainer.TrainBinary(ML, new LogisticRegressionBinaryClassificationTrainer.Options() { FeatureColumnName = "Features", LabelColumnName = DefaultColumnNames.Label, @@ -748,7 +748,7 @@ public void TestEnsembleCombiner() TrainingData = dataView, NormalizeFeatures = NormalizeOption.No }).PredictorModel, - LogisticRegression.TrainBinary(ML, new LogisticRegression.Options() + LogisticRegressionBinaryClassificationTrainer.TrainBinary(ML, new LogisticRegressionBinaryClassificationTrainer.Options() { FeatureColumnName = "Features", LabelColumnName = DefaultColumnNames.Label, @@ -777,7 +777,7 @@ public void TestMultiClassEnsembleCombiner() LabelColumnName = DefaultColumnNames.Label, TrainingData = dataView }).PredictorModel, - LogisticRegression.TrainMultiClass(Env, new MulticlassLogisticRegression.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, - LogisticRegression.TrainMultiClass(Env, new MulticlassLogisticRegression.Options() + LogisticRegressionBinaryClassificationTrainer.TrainMultiClass(Env, new LogisticRegressionMulticlassClassificationTrainer.Options() { FeatureColumnName = "Features", LabelColumnName = DefaultColumnNames.Label, diff --git a/test/Microsoft.ML.StaticPipelineTesting/Training.cs b/test/Microsoft.ML.StaticPipelineTesting/Training.cs index 11e76586f0..dce9837022 100644 --- a/test/Microsoft.ML.StaticPipelineTesting/Training.cs +++ b/test/Microsoft.ML.StaticPipelineTesting/Training.cs @@ -118,7 +118,7 @@ public void SdcaBinaryClassification() var est = reader.MakeNewEstimator() .Append(r => (r.label, preds: catalog.Trainers.Sdca(r.label, r.features, null, - new SdcaBinaryTrainer.Options { MaximumNumberOfIterations = 2, NumberOfThreads = 1 }, + new SdcaCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 2, NumberOfThreads = 1 }, onFit: (p) => { pred = p; }))); var pipe = reader.Append(est); @@ -198,7 +198,7 @@ public void SdcaBinaryClassificationNoCalibration() // With a custom loss function we no longer get calibrated predictions. var est = reader.MakeNewEstimator() .Append(r => (r.label, preds: catalog.Trainers.SdcaNonCalibrated(r.label, r.features, null, loss, - new SdcaNonCalibratedBinaryTrainer.Options { MaximumNumberOfIterations = 2, NumberOfThreads = 1 }, + new SdcaNonCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 2, NumberOfThreads = 1 }, onFit: p => pred = p))); var pipe = reader.Append(est); @@ -618,7 +618,7 @@ public void PoissonRegression() var est = reader.MakeNewEstimator() .Append(r => (r.label, score: catalog.Trainers.PoissonRegression(r.label, r.features, null, - new PoissonRegression.Options { L2Regularization = 2, EnforceNonNegativity = true, NumberOfThreads = 1 }, + new PoissonRegressionTrainer.Options { L2Regularization = 2, EnforceNonNegativity = true, NumberOfThreads = 1 }, onFit: (p) => { pred = p; }))); var pipe = reader.Append(est); @@ -655,7 +655,7 @@ public void LogisticRegressionBinaryClassification() var est = reader.MakeNewEstimator() .Append(r => (r.label, preds: catalog.Trainers.LogisticRegressionBinaryClassifier(r.label, r.features, null, - new LogisticRegression.Options { L1Regularization = 10, NumberOfThreads = 1 }, onFit: (p) => { pred = p; }))); + new LogisticRegressionBinaryClassificationTrainer.Options { L1Regularization = 10, NumberOfThreads = 1 }, onFit: (p) => { pred = p; }))); var pipe = reader.Append(est); @@ -695,7 +695,7 @@ public void MulticlassLogisticRegression() r.label, r.features, null, - new MulticlassLogisticRegression.Options { NumberOfThreads = 1 }, + new LogisticRegressionMulticlassClassificationTrainer.Options { NumberOfThreads = 1 }, onFit: p => pred = p))); var pipe = reader.Append(est); @@ -784,7 +784,7 @@ public void KMeans() ( r.features, null, - options: new KMeansPlusPlusTrainer.Options + options: new KMeansTrainer.Options { NumberOfClusters = 3, NumberOfThreads = 1 @@ -1009,7 +1009,7 @@ public void HogwildSGDLogisticRegression() var est = reader.MakeNewEstimator() .Append(r => (r.label, preds: catalog.Trainers.StochasticGradientDescentClassificationTrainer(r.label, r.features, null, - new SgdBinaryTrainer.Options { L2Regularization = 0, NumberOfThreads = 1 }, + new SgdCalibratedTrainer.Options { L2Regularization = 0, NumberOfThreads = 1 }, onFit: (p) => { pred = p; }))); var pipe = reader.Append(est); @@ -1082,7 +1082,7 @@ public void HogwildSGDSupportVectorMachine() var est = reader.MakeNewEstimator() .Append(r => (r.label, preds: catalog.Trainers.StochasticGradientDescentNonCalibratedClassificationTrainer(r.label, r.features, null, - new SgdNonCalibratedBinaryTrainer.Options { L2Regularization = 0, NumberOfThreads = 1, Loss = new HingeLoss()}, + new SgdNonCalibratedTrainer.Options { L2Regularization = 0, NumberOfThreads = 1, Loss = new HingeLoss()}, onFit: (p) => { pred = p; }))); var pipe = reader.Append(est); diff --git a/test/Microsoft.ML.Tests/AnomalyDetectionTests.cs b/test/Microsoft.ML.Tests/AnomalyDetectionTests.cs index b6020f33b8..2d96e306d6 100644 --- a/test/Microsoft.ML.Tests/AnomalyDetectionTests.cs +++ b/test/Microsoft.ML.Tests/AnomalyDetectionTests.cs @@ -59,13 +59,13 @@ public static void RandomizedPcaInMemory() var mlContext = new MLContext(seed: 0); // Create an anomaly detector. Its underlying algorithm is randomized PCA. - var trainer1 = mlContext.AnomalyDetection.Trainers.AnalyzeRandomizedPrincipalComponents(featureColumnName: nameof(DataPoint.Features), rank: 1, ensureZeroMean: false); + var trainer1 = mlContext.AnomalyDetection.Trainers.RandomizedPca(featureColumnName: nameof(DataPoint.Features), rank: 1, ensureZeroMean: false); // Test the first detector. ExecutePipelineWithGivenRandomizedPcaTrainer(mlContext, trainer1); // Object required in the creation of another detector. - var options = new Trainers.RandomizedPrincipalComponentAnalyzer.Options() + var options = new Trainers.RandomizedPcaTrainer.Options() { FeatureColumnName = nameof(DataPoint.Features), Rank = 1, @@ -73,7 +73,7 @@ public static void RandomizedPcaInMemory() }; // Create anther anomaly detector. Its underlying algorithm is randomized PCA. - var trainer2 = mlContext.AnomalyDetection.Trainers.AnalyzeRandomizedPrincipalComponents(options); + var trainer2 = mlContext.AnomalyDetection.Trainers.RandomizedPca(options); // Test the second detector. ExecutePipelineWithGivenRandomizedPcaTrainer(mlContext, trainer2); @@ -102,7 +102,7 @@ private class Result /// /// Help function used to execute trainers defined in . /// - private static void ExecutePipelineWithGivenRandomizedPcaTrainer(MLContext mlContext, Trainers.RandomizedPrincipalComponentAnalyzer trainer) + private static void ExecutePipelineWithGivenRandomizedPcaTrainer(MLContext mlContext, Trainers.RandomizedPcaTrainer trainer) { var samples = new List() { @@ -152,7 +152,7 @@ private IDataView DetectAnomalyInMnistOneClass(string trainPath, string testPath var trainData = loader.Load(trainPath); var testData = loader.Load(testPath); - var trainer = ML.AnomalyDetection.Trainers.AnalyzeRandomizedPrincipalComponents(); + var trainer = ML.AnomalyDetection.Trainers.RandomizedPca(); var model = trainer.Fit(trainData); return model.Transform(testData); diff --git a/test/Microsoft.ML.Tests/FeatureContributionTests.cs b/test/Microsoft.ML.Tests/FeatureContributionTests.cs index b59cbb1d0a..ba3f83e5d6 100644 --- a/test/Microsoft.ML.Tests/FeatureContributionTests.cs +++ b/test/Microsoft.ML.Tests/FeatureContributionTests.cs @@ -28,7 +28,7 @@ public FeatureContributionTests(ITestOutputHelper output) : base(output) public void FeatureContributionEstimatorWorkout() { var data = GetSparseDataset(); - var model = ML.Regression.Trainers.OrdinaryLeastSquares().Fit(data); + var model = ML.Regression.Trainers.Ols().Fit(data); var estPipe = new FeatureContributionCalculatingEstimator(ML, model.Model, model.FeatureColumn) .Append(new FeatureContributionCalculatingEstimator(ML, model.Model, model.FeatureColumn, normalize: false)) @@ -44,7 +44,7 @@ public void FeatureContributionEstimatorWorkout() [Fact] public void TestOrdinaryLeastSquaresRegression() { - TestFeatureContribution(ML.Regression.Trainers.OrdinaryLeastSquares(), GetSparseDataset(numberOfInstances: 100), "LeastSquaresRegression"); + TestFeatureContribution(ML.Regression.Trainers.Ols(), GetSparseDataset(numberOfInstances: 100), "LeastSquaresRegression"); } [LightGBMFact] @@ -74,7 +74,7 @@ public void TestFastTreeTweedieRegression() [Fact] public void TestSDCARegression() { - TestFeatureContribution(ML.Regression.Trainers.StochasticDualCoordinateAscent( + TestFeatureContribution(ML.Regression.Trainers.Sdca( new SdcaRegressionTrainer.Options { NumberOfThreads = 1, }), GetSparseDataset(numberOfInstances: 100), "SDCARegression"); } @@ -88,13 +88,13 @@ public void TestOnlineGradientDescentRegression() public void TestPoissonRegression() { TestFeatureContribution(ML.Regression.Trainers.PoissonRegression( - new PoissonRegression.Options { NumberOfThreads = 1 }), GetSparseDataset(numberOfInstances: 100), "PoissonRegression"); + new PoissonRegressionTrainer.Options { NumberOfThreads = 1 }), GetSparseDataset(numberOfInstances: 100), "PoissonRegression"); } [Fact] public void TestGAMRegression() { - TestFeatureContribution(ML.Regression.Trainers.GeneralizedAdditiveModels(), GetSparseDataset(numberOfInstances: 100), "GAMRegression"); + TestFeatureContribution(ML.Regression.Trainers.Gam(), GetSparseDataset(numberOfInstances: 100), "GAMRegression"); } // Tests for ranking trainers that implement IFeatureContributionMapper interface. @@ -120,7 +120,7 @@ public void TestAveragePerceptronBinary() [Fact] public void TestSVMBinary() { - TestFeatureContribution(ML.BinaryClassification.Trainers.LinearSupportVectorMachines(), GetSparseDataset(TaskType.BinaryClassification, 100), "SVMBinary"); + TestFeatureContribution(ML.BinaryClassification.Trainers.LinearSvm(), GetSparseDataset(TaskType.BinaryClassification, 100), "SVMBinary"); } [Fact] @@ -150,28 +150,28 @@ public void TestLightGbmBinary() [Fact] public void TestSDCABinary() { - TestFeatureContribution(ML.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1, }), GetSparseDataset(TaskType.BinaryClassification, 100), "SDCABinary", precision: 5); + TestFeatureContribution(ML.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1, }), GetSparseDataset(TaskType.BinaryClassification, 100), "SDCABinary", precision: 5); } [Fact] public void TestSGDBinary() { - TestFeatureContribution(ML.BinaryClassification.Trainers.StochasticGradientDescent( - new SgdBinaryTrainer.Options { NumberOfThreads = 1 }), + TestFeatureContribution(ML.BinaryClassification.Trainers.SgdCalibrated( + new SgdCalibratedTrainer.Options { NumberOfThreads = 1 }), GetSparseDataset(TaskType.BinaryClassification, 100), "SGDBinary"); } [Fact] public void TestSSGDBinary() { - TestFeatureContribution(ML.BinaryClassification.Trainers.SymbolicStochasticGradientDescent(), GetSparseDataset(TaskType.BinaryClassification, 100), "SSGDBinary", 4); + TestFeatureContribution(ML.BinaryClassification.Trainers.SymbolicSgd(), GetSparseDataset(TaskType.BinaryClassification, 100), "SSGDBinary", 4); } [Fact] public void TestGAMBinary() { - TestFeatureContribution(ML.BinaryClassification.Trainers.GeneralizedAdditiveModels(), GetSparseDataset(TaskType.BinaryClassification, 100), "GAMBinary"); + TestFeatureContribution(ML.BinaryClassification.Trainers.Gam(), GetSparseDataset(TaskType.BinaryClassification, 100), "GAMBinary"); } private void TestFeatureContribution( diff --git a/test/Microsoft.ML.Tests/OnnxConversionTest.cs b/test/Microsoft.ML.Tests/OnnxConversionTest.cs index d9473608ea..6ca09ac5ab 100644 --- a/test/Microsoft.ML.Tests/OnnxConversionTest.cs +++ b/test/Microsoft.ML.Tests/OnnxConversionTest.cs @@ -59,7 +59,7 @@ public void SimpleEndToEndOnnxConversionTest() var dynamicPipeline = mlContext.Transforms.Normalize("FeatureVector") .AppendCacheCheckpoint(mlContext) - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent(new SdcaRegressionTrainer.Options() { + .Append(mlContext.Regression.Trainers.Sdca(new SdcaRegressionTrainer.Options() { LabelColumnName = "Target", FeatureColumnName = "FeatureVector", NumberOfThreads = 1 @@ -138,13 +138,13 @@ public void KmeansOnnxConversionTest() hasHeader: true); var pipeline = mlContext.Transforms.Normalize("Features"). - Append(mlContext.Clustering.Trainers.KMeans(new Trainers.KMeansPlusPlusTrainer.Options + Append(mlContext.Clustering.Trainers.KMeans(new Trainers.KMeansTrainer.Options { FeatureColumnName = DefaultColumnNames.Features, MaximumNumberOfIterations = 1, NumberOfClusters = 4, NumberOfThreads = 1, - InitializationAlgorithm = Trainers.KMeansPlusPlusTrainer.InitializationAlgorithm.Random + InitializationAlgorithm = Trainers.KMeansTrainer.InitializationAlgorithm.Random })); var model = pipeline.Fit(data); @@ -317,7 +317,7 @@ public void LogisticRegressionOnnxConversionTest() var dynamicPipeline = mlContext.Transforms.Normalize("FeatureVector") .AppendCacheCheckpoint(mlContext) - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent(new SdcaRegressionTrainer.Options() { + .Append(mlContext.Regression.Trainers.Sdca(new SdcaRegressionTrainer.Options() { LabelColumnName = "Target", FeatureColumnName = "FeatureVector", NumberOfThreads = 1 @@ -385,7 +385,7 @@ public void MulticlassLogisticRegressionOnnxConversionTest() var pipeline = mlContext.Transforms.Normalize("Features"). Append(mlContext.Transforms.Conversion.MapValueToKey("Label")). - Append(mlContext.MulticlassClassification.Trainers.LogisticRegression(new MulticlassLogisticRegression.Options() { NumberOfThreads = 1 })); + Append(mlContext.MulticlassClassification.Trainers.LogisticRegression(new LogisticRegressionMulticlassClassificationTrainer.Options() { NumberOfThreads = 1 })); var model = pipeline.Fit(data); var transformedData = model.Transform(data); diff --git a/test/Microsoft.ML.Tests/PermutationFeatureImportanceTests.cs b/test/Microsoft.ML.Tests/PermutationFeatureImportanceTests.cs index 51c700d74d..49fe2f4301 100644 --- a/test/Microsoft.ML.Tests/PermutationFeatureImportanceTests.cs +++ b/test/Microsoft.ML.Tests/PermutationFeatureImportanceTests.cs @@ -153,7 +153,7 @@ public void TestPfiBinaryClassificationOnDenseFeatures() { var data = GetDenseDataset(TaskType.BinaryClassification); var model = ML.BinaryClassification.Trainers.LogisticRegression( - new LogisticRegression.Options { NumberOfThreads = 1 }).Fit(data); + new LogisticRegressionBinaryClassificationTrainer.Options { NumberOfThreads = 1 }).Fit(data); var pfi = ML.BinaryClassification.PermutationFeatureImportance(model, data); // Pfi Indices: @@ -191,7 +191,7 @@ public void TestPfiBinaryClassificationOnSparseFeatures() { var data = GetSparseDataset(TaskType.BinaryClassification); var model = ML.BinaryClassification.Trainers.LogisticRegression( - new LogisticRegression.Options { NumberOfThreads = 1 }).Fit(data); + new LogisticRegressionBinaryClassificationTrainer.Options { NumberOfThreads = 1 }).Fit(data); var pfi = ML.BinaryClassification.PermutationFeatureImportance(model, data); // Pfi Indices: @@ -270,7 +270,8 @@ public void TestPfiMulticlassClassificationOnSparseFeatures() { var data = GetSparseDataset(TaskType.MulticlassClassification); var model = ML.MulticlassClassification.Trainers.LogisticRegression( - new MulticlassLogisticRegression.Options { MaximumNumberOfIterations = 1000 }).Fit(data); + new LogisticRegressionMulticlassClassificationTrainer.Options { MaximumNumberOfIterations = 1000 }).Fit(data); + var pfi = ML.MulticlassClassification.PermutationFeatureImportance(model, data); // Pfi Indices: diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/CookbookSamples/CookbookSamplesDynamicApi.cs b/test/Microsoft.ML.Tests/Scenarios/Api/CookbookSamples/CookbookSamplesDynamicApi.cs index c8f7abee2f..1bf3d4d397 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/CookbookSamples/CookbookSamplesDynamicApi.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/CookbookSamples/CookbookSamplesDynamicApi.cs @@ -105,7 +105,7 @@ private void TrainRegression(string trainDataPath, string testDataPath, string m // once so adding a caching step before it is not helpful. .AppendCacheCheckpoint(mlContext) // Add the SDCA regression trainer. - .Append(mlContext.Regression.Trainers.StochasticDualCoordinateAscent(labelColumnName: "Target", featureColumnName: "FeatureVector")); + .Append(mlContext.Regression.Trainers.Sdca(labelColumnName: "Target", featureColumnName: "FeatureVector")); // Step three. Fit the pipeline to the training data. var model = pipeline.Fit(trainData); @@ -165,7 +165,7 @@ private ITransformer TrainOnIris(string irisDataPath) // Cache data in memory for steps after the cache check point stage. .AppendCacheCheckpoint(mlContext) // Use the multi-class SDCA model to predict the label using features. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.MulticlassClassification.Trainers.Sdca()); // Train the model. var trainedModel = pipeline.Fit(trainData); @@ -423,7 +423,7 @@ private void CrossValidationOn(string dataPath) // Notice that unused part in the data may not be cached. .AppendCacheCheckpoint(mlContext) // Use the multi-class SDCA model to predict the label using features. - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.MulticlassClassification.Trainers.Sdca()); // Split the data 90:10 into train and test sets, train and evaluate. var split = mlContext.Data.TrainTestSplit(data, testFraction: 0.1); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/DecomposableTrainAndPredict.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/DecomposableTrainAndPredict.cs index b4e82c1f09..441732aa39 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/DecomposableTrainAndPredict.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/DecomposableTrainAndPredict.cs @@ -31,8 +31,8 @@ void DecomposableTrainAndPredict() var pipeline = new ColumnConcatenatingEstimator (ml, "Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth") .Append(new ValueToKeyMappingEstimator(ml, "Label"), TransformerScope.TrainTest) - .Append(ml.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1, })) + .Append(ml.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1, })) .Append(new KeyToValueMappingEstimator(ml, "PredictedLabel")); var model = pipeline.Fit(data).GetModelFor(TransformerScope.Scoring); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Extensibility.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Extensibility.cs index 9517cd45d6..e04a0ca6f1 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Extensibility.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Extensibility.cs @@ -40,8 +40,8 @@ void Extensibility() var pipeline = new ColumnConcatenatingEstimator (ml, "Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth") .Append(new CustomMappingEstimator(ml, action, null), TransformerScope.TrainTest) .Append(new ValueToKeyMappingEstimator(ml, "Label"), TransformerScope.TrainTest) - .Append(ml.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 })) + .Append(ml.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 })) .Append(new KeyToValueMappingEstimator(ml, "PredictedLabel")); var model = pipeline.Fit(data).GetModelFor(TransformerScope.Scoring); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Metacomponents.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Metacomponents.cs index 6f909cef69..9e9411a2f9 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Metacomponents.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Metacomponents.cs @@ -23,8 +23,8 @@ public void Metacomponents() var ml = new MLContext(); var data = ml.Data.LoadFromTextFile(GetDataPath(TestDatasets.irisData.trainFilename), separatorChar: ','); - var sdcaTrainer = ml.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1, }); + var sdcaTrainer = ml.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1, }); var pipeline = new ColumnConcatenatingEstimator (ml, "Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth") .Append(ml.Transforms.Conversion.MapValueToKey("Label"), TransformerScope.TrainTest) diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/MultithreadedPrediction.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/MultithreadedPrediction.cs index 843795ed75..bac7c98229 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/MultithreadedPrediction.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/MultithreadedPrediction.cs @@ -29,8 +29,8 @@ void MultithreadedPrediction() // Pipeline. var pipeline = ml.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(ml) - .Append(ml.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1 })); + .Append(ml.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train. var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/PredictAndMetadata.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/PredictAndMetadata.cs index 7c166f81f3..c293ec6970 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/PredictAndMetadata.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/PredictAndMetadata.cs @@ -29,8 +29,8 @@ void PredictAndMetadata() var pipeline = ml.Transforms.Concatenate("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth") .Append(ml.Transforms.Conversion.MapValueToKey("Label"), TransformerScope.TrainTest) - .Append(ml.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1, })); + .Append(ml.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1, })); var model = pipeline.Fit(data).GetModelFor(TransformerScope.Scoring); var engine = model.CreatePredictionEngine(ml); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/SimpleTrainAndPredict.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/SimpleTrainAndPredict.cs index 154bac9986..0b7c8fd430 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/SimpleTrainAndPredict.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/SimpleTrainAndPredict.cs @@ -26,8 +26,8 @@ public void SimpleTrainAndPredict() // Pipeline. var pipeline = ml.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(ml) - .Append(ml.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1 })); + .Append(ml.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train. var model = pipeline.Fit(data); @@ -63,7 +63,7 @@ public void SimpleTrainAndPredictSymSGD() // Pipeline. var pipeline = ml.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(ml) - .Append(ml.BinaryClassification.Trainers.SymbolicStochasticGradientDescent(new SymbolicStochasticGradientDescentClassificationTrainer.Options + .Append(ml.BinaryClassification.Trainers.SymbolicSgd(new SymbolicSgdTrainer.Options { NumberOfThreads = 1 })); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainSaveModelAndPredict.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainSaveModelAndPredict.cs index e662657801..f5603f633b 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainSaveModelAndPredict.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainSaveModelAndPredict.cs @@ -28,8 +28,8 @@ public void TrainSaveModelAndPredict() // Pipeline. var pipeline = ml.Transforms.Text.FeaturizeText("Features", "SentimentText") .AppendCacheCheckpoint(ml) - .Append(ml.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1 })); + .Append(ml.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 })); // Train. var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainWithInitialPredictor.cs b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainWithInitialPredictor.cs index 2b7e3ee85b..4f28e8ff4d 100644 --- a/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainWithInitialPredictor.cs +++ b/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/TrainWithInitialPredictor.cs @@ -31,8 +31,8 @@ public void TrainWithInitialPredictor() var trainData = ml.Data.Cache(pipeline.Fit(data).Transform(data)); // Train the first predictor. - var trainer = ml.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1 }); + var trainer = ml.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { NumberOfThreads = 1 }); var firstModel = trainer.Fit(trainData); diff --git a/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationTests.cs b/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationTests.cs index c8cf115396..e813d5c9c7 100644 --- a/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationTests.cs +++ b/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationTests.cs @@ -32,8 +32,8 @@ public void TrainAndPredictIrisModelTest() .Append(mlContext.Transforms.Normalize("Features")) .Append(mlContext.Transforms.Conversion.MapValueToKey("Label")) .AppendCacheCheckpoint(mlContext) - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { NumberOfThreads = 1 })); + .Append(mlContext.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { NumberOfThreads = 1 })); // Read training and test data sets string dataPath = GetDataPath(TestDatasets.iris.trainFilename); diff --git a/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationWithStringLabelTests.cs b/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationWithStringLabelTests.cs index 1534c2b77e..d86b605d1a 100644 --- a/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationWithStringLabelTests.cs +++ b/test/Microsoft.ML.Tests/Scenarios/IrisPlantClassificationWithStringLabelTests.cs @@ -37,8 +37,8 @@ public void TrainAndPredictIrisModelWithStringLabelTest() .Append(mlContext.Transforms.Normalize("Features")) .Append(mlContext.Transforms.Conversion.MapValueToKey("Label", "IrisPlantType"), TransformerScope.TrainTest) .AppendCacheCheckpoint(mlContext) - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { NumberOfThreads = 1 })) + .Append(mlContext.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { NumberOfThreads = 1 })) .Append(mlContext.Transforms.Conversion.MapKeyToValue(("Plant", "PredictedLabel"))); // Train the pipeline diff --git a/test/Microsoft.ML.Tests/Scenarios/OvaTest.cs b/test/Microsoft.ML.Tests/Scenarios/OvaTest.cs index 3b4de327bc..321afb876b 100644 --- a/test/Microsoft.ML.Tests/Scenarios/OvaTest.cs +++ b/test/Microsoft.ML.Tests/Scenarios/OvaTest.cs @@ -138,7 +138,7 @@ public void OvaLinearSvm() // Pipeline var pipeline = mlContext.MulticlassClassification.Trainers.OneVersusAll( - mlContext.BinaryClassification.Trainers.LinearSupportVectorMachines(new LinearSvmTrainer.Options { NumberOfIterations = 100 }), + mlContext.BinaryClassification.Trainers.LinearSvm(new LinearSvmTrainer.Options { NumberOfIterations = 100 }), useProbabilities: false); var model = pipeline.Fit(data); diff --git a/test/Microsoft.ML.Tests/Scenarios/TensorflowTests.cs b/test/Microsoft.ML.Tests/Scenarios/TensorflowTests.cs index e4ec4bf58d..45fe3977f1 100644 --- a/test/Microsoft.ML.Tests/Scenarios/TensorflowTests.cs +++ b/test/Microsoft.ML.Tests/Scenarios/TensorflowTests.cs @@ -39,7 +39,7 @@ public void TensorFlowTransforCifarEndToEndTest() .Append(new ColumnConcatenatingEstimator(mlContext, "Features", "Output")) .Append(new ValueToKeyMappingEstimator(mlContext, "Label")) .AppendCacheCheckpoint(mlContext) - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent()); + .Append(mlContext.MulticlassClassification.Trainers.Sdca()); var transformer = pipeEstimator.Fit(data); diff --git a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs index 3390b677ca..609c0f202b 100644 --- a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs +++ b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/IrisPlantClassificationTests.cs @@ -30,8 +30,8 @@ public void TrainAndPredictIrisModelUsingDirectInstantiationTest() .Append(mlContext.Transforms.Normalize("Features")) .Append(mlContext.Transforms.Conversion.MapValueToKey("Label")) .AppendCacheCheckpoint(mlContext) - .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { NumberOfThreads = 1 })); + .Append(mlContext.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { NumberOfThreads = 1 })); // Read training and test data sets string dataPath = GetDataPath(TestDatasets.iris.trainFilename); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs b/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs index 2ea971e096..616f98231b 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/FAFMEstimator.cs @@ -19,7 +19,7 @@ public void FfmBinaryClassificationWithAdvancedArguments() var data = DatasetUtils.GenerateFfmSamples(500); var dataView = mlContext.Data.LoadFromEnumerable(data); - var ffmArgs = new FieldAwareFactorizationMachineBinaryClassificationTrainer.Options(); + var ffmArgs = new FieldAwareFactorizationMachineTrainer.Options(); // Customized the field names. ffmArgs.FeatureColumnName = nameof(DatasetUtils.FfmExample.Field0); // First field. @@ -44,7 +44,7 @@ public void FieldAwareFactorizationMachine_Estimator() var data = new TextLoader(Env, GetFafmBCLoaderArgs()) .Load(GetDataPath(TestDatasets.breastCancer.trainFilename)); - var ffmArgs = new FieldAwareFactorizationMachineBinaryClassificationTrainer.Options { + var ffmArgs = new FieldAwareFactorizationMachineTrainer.Options { FeatureColumnName = "Feature1", // Features from the 1st field. ExtraFeatureColumns = new[] { "Feature2", "Feature3", "Feature4" }, // 2nd field's feature column, 3rd field's feature column, 4th field's feature column. Shuffle = false, diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs index d8483f6ee5..d5bbbd4094 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs @@ -57,7 +57,7 @@ public void TestLogisticRegressionNoStats() { (IEstimator pipe, IDataView dataView) = GetBinaryClassificationPipeline(); - pipe = pipe.Append(ML.BinaryClassification.Trainers.LogisticRegression(new LogisticRegression.Options { ShowTrainingStatistics = true })); + pipe = pipe.Append(ML.BinaryClassification.Trainers.LogisticRegression(new LogisticRegressionBinaryClassificationTrainer.Options { ShowTrainingStatistics = true })); var transformerChain = pipe.Fit(dataView) as TransformerChain>>; var linearModel = transformerChain.LastTransformer.Model.SubModel as LinearBinaryModelParameters; @@ -74,7 +74,7 @@ public void TestLogisticRegressionWithStats() (IEstimator pipe, IDataView dataView) = GetBinaryClassificationPipeline(); pipe = pipe.Append(ML.BinaryClassification.Trainers.LogisticRegression( - new LogisticRegression.Options + new LogisticRegressionBinaryClassificationTrainer.Options { ShowTrainingStatistics = true, ComputeStandardDeviation = new ComputeLRTrainingStdThroughMkl(), diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs index 51df6e7189..ed907e4de0 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/MetalinearEstimators.cs @@ -41,8 +41,8 @@ public void OVAWithAllConstructorArgs() public void OVAUncalibrated() { var (pipeline, data) = GetMultiClassPipeline(); - var sdcaTrainer = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 }); + var sdcaTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 }); pipeline = pipeline.Append(ML.MulticlassClassification.Trainers.OneVersusAll(sdcaTrainer, useProbabilities: false)) .Append(new KeyToValueMappingEstimator(Env, "PredictedLabel")); @@ -59,8 +59,8 @@ public void PairwiseCouplingTrainer() { var (pipeline, data) = GetMultiClassPipeline(); - var sdcaTrainer = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 }); + var sdcaTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { MaximumNumberOfIterations = 100, Shuffle = true, NumberOfThreads = 1 }); pipeline = pipeline.Append(ML.MulticlassClassification.Trainers.PairwiseCoupling(sdcaTrainer)) .Append(ML.Transforms.Conversion.MapKeyToValue("PredictedLabel")); @@ -82,8 +82,8 @@ public void MetacomponentsFeaturesRenamed() var data = loader.Load(GetDataPath(TestDatasets.irisData.trainFilename)); - var sdcaTrainer = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { + var sdcaTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { LabelColumnName = "Label", FeatureColumnName = "Vars", MaximumNumberOfIterations = 100, diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/OlsLinearRegressionTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/OlsLinearRegressionTests.cs index cace14d6e0..5787a7aaa6 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/OlsLinearRegressionTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/OlsLinearRegressionTests.cs @@ -14,7 +14,7 @@ public partial class TrainerEstimators public void TestEstimatorOlsLinearRegression() { var dataView = GetRegressionPipeline(); - var trainer = ML.Regression.Trainers.OrdinaryLeastSquares(new OrdinaryLeastSquaresRegressionTrainer.Options()); + var trainer = ML.Regression.Trainers.Ols(new OlsTrainer.Options()); TestEstimatorCore(trainer, dataView); var model = trainer.Fit(dataView); @@ -22,7 +22,7 @@ public void TestEstimatorOlsLinearRegression() Assert.NotEmpty(model.Model.StandardErrors); Assert.NotEmpty(model.Model.PValues); Assert.NotEmpty(model.Model.TValues); - trainer = ML.Regression.Trainers.OrdinaryLeastSquares(new OrdinaryLeastSquaresRegressionTrainer.Options() { CalculateStatistics = false }); + trainer = ML.Regression.Trainers.Ols(new OlsTrainer.Options() { CalculateStatistics = false }); model = trainer.Fit(dataView); Assert.False(model.Model.HasStatistics); Done(); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/OnlineLinearTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/OnlineLinearTests.cs index 73f4d85ddb..08e889c600 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/OnlineLinearTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/OnlineLinearTests.cs @@ -43,7 +43,7 @@ public void OnlineLinearWorkout() var apModel = apTrainer.Fit(binaryTrainData); apTrainer.Fit(binaryTrainData, apModel.Model); - var svmTrainer = ML.BinaryClassification.Trainers.LinearSupportVectorMachines(); + var svmTrainer = ML.BinaryClassification.Trainers.LinearSvm(); TestEstimatorCore(svmTrainer, binaryTrainData); var svmModel = svmTrainer.Fit(binaryTrainData); diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/SdcaTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/SdcaTests.cs index 10976d9b5d..312c484ef9 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/SdcaTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/SdcaTests.cs @@ -23,21 +23,22 @@ public void SdcaWorkout() var binaryData = ML.Transforms.Conversion.ConvertType("Label", outputKind: DataKind.Boolean) .Fit(data.AsDynamic).Transform(data.AsDynamic); - var binaryTrainer = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaBinaryTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); + var binaryTrainer = ML.BinaryClassification.Trainers.SdcaCalibrated( + new SdcaCalibratedBinaryClassificationTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); TestEstimatorCore(binaryTrainer, binaryData); - var nonCalibratedBinaryTrainer = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( - new SdcaNonCalibratedBinaryTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); + var nonCalibratedBinaryTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( + new SdcaNonCalibratedBinaryClassificationTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); TestEstimatorCore(nonCalibratedBinaryTrainer, binaryData); - var regressionTrainer = ML.Regression.Trainers.StochasticDualCoordinateAscent( + var regressionTrainer = ML.Regression.Trainers.Sdca( new SdcaRegressionTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); + TestEstimatorCore(regressionTrainer, data.AsDynamic); var mcData = ML.Transforms.Conversion.MapValueToKey("Label").Fit(data.AsDynamic).Transform(data.AsDynamic); - var mcTrainer = ML.MulticlassClassification.Trainers.StochasticDualCoordinateAscent( - new SdcaMultiClassTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); + var mcTrainer = ML.MulticlassClassification.Trainers.Sdca( + new SdcaMulticlassClassificationTrainer.Options { ConvergenceTolerance = 1e-2f, MaximumNumberOfIterations = 10 }); TestEstimatorCore(mcTrainer, mcData); Done(); @@ -62,7 +63,7 @@ public void SdcaLogisticRegression() // Step 2: Create a binary classifier. // We set the "Label" column as the label of the dataset, and the "Features" column as the features column. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(labelColumnName: "Label", featureColumnName: "Features", l2Regularization: 0.001f); + var pipeline = mlContext.BinaryClassification.Trainers.SdcaCalibrated(labelColumnName: "Label", featureColumnName: "Features", l2Regularization: 0.001f); // Step 3: Train the pipeline created. var model = pipeline.Fit(data); @@ -106,7 +107,7 @@ public void SdcaSupportVectorMachine() // Step 2: Create a binary classifier. // We set the "Label" column as the label of the dataset, and the "Features" column as the features column. - var pipeline = mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated( + var pipeline = mlContext.BinaryClassification.Trainers.SdcaNonCalibrated( labelColumnName: "Label", featureColumnName: "Features", loss: new HingeLoss(), l2Regularization: 0.001f); // Step 3: Train the pipeline created. diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/SymSgdClassificationTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/SymSgdClassificationTests.cs index de14f52c56..5d1774fd62 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/SymSgdClassificationTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/SymSgdClassificationTests.cs @@ -16,7 +16,7 @@ public partial class TrainerEstimators public void TestEstimatorSymSgdClassificationTrainer() { (var pipe, var dataView) = GetBinaryClassificationPipeline(); - var trainer = new SymbolicStochasticGradientDescentClassificationTrainer(Env, new SymbolicStochasticGradientDescentClassificationTrainer.Options()); + var trainer = new SymbolicSgdTrainer(Env, new SymbolicSgdTrainer.Options()); var pipeWithTrainer = pipe.Append(trainer); TestEstimatorCore(pipeWithTrainer, dataView); @@ -32,14 +32,14 @@ public void TestEstimatorSymSgdInitPredictor() (var pipe, var dataView) = GetBinaryClassificationPipeline(); var transformedData = pipe.Fit(dataView).Transform(dataView); - var initPredictor = ML.BinaryClassification.Trainers.StochasticDualCoordinateAscent().Fit(transformedData); + var initPredictor = ML.BinaryClassification.Trainers.SdcaCalibrated().Fit(transformedData); var data = initPredictor.Transform(transformedData); - var withInitPredictor = new SymbolicStochasticGradientDescentClassificationTrainer(Env, new SymbolicStochasticGradientDescentClassificationTrainer.Options()).Fit(transformedData, + var withInitPredictor = new SymbolicSgdTrainer(Env, new SymbolicSgdTrainer.Options()).Fit(transformedData, modelParameters: initPredictor.Model.SubModel); var outInitData = withInitPredictor.Transform(transformedData); - var notInitPredictor = new SymbolicStochasticGradientDescentClassificationTrainer(Env, new SymbolicStochasticGradientDescentClassificationTrainer.Options()).Fit(transformedData); + var notInitPredictor = new SymbolicSgdTrainer(Env, new SymbolicSgdTrainer.Options()).Fit(transformedData); var outNoInitData = notInitPredictor.Transform(transformedData); int numExamples = 10; diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs index 800fac7162..69b8aa0c1f 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/TrainerEstimators.cs @@ -41,7 +41,7 @@ public void PCATrainerEstimator() // Pipeline. - var pipeline = new RandomizedPrincipalComponentAnalyzer(Env, featureColumn, rank: 10); + var pipeline = new RandomizedPcaTrainer(Env, featureColumn, rank: 10); TestEstimatorCore(pipeline, data); Done(); @@ -71,11 +71,11 @@ public void KMeansEstimator() // Pipeline. - var pipeline = new KMeansPlusPlusTrainer(Env, new KMeansPlusPlusTrainer.Options + var pipeline = new KMeansTrainer(Env, new KMeansTrainer.Options { FeatureColumnName = featureColumn, ExampleWeightColumnName = weights, - InitializationAlgorithm = KMeansPlusPlusTrainer.InitializationAlgorithm.KMeansYinyang, + InitializationAlgorithm = KMeansTrainer.InitializationAlgorithm.KMeansYinyang, }); TestEstimatorCore(pipeline, data); @@ -89,8 +89,8 @@ public void KMeansEstimator() [Fact] public void TestEstimatorHogwildSGD() { - var trainers = new[] { ML.BinaryClassification.Trainers.StochasticGradientDescent(l2Regularization: 0, numberOfIterations: 80), - ML.BinaryClassification.Trainers.StochasticGradientDescent(new Trainers.SgdBinaryTrainer.Options(){ L2Regularization = 0, NumberOfIterations = 80})}; + var trainers = new[] { ML.BinaryClassification.Trainers.SgdCalibrated(l2Regularization: 0, numberOfIterations: 80), + ML.BinaryClassification.Trainers.SgdCalibrated(new Trainers.SgdCalibratedTrainer.Options(){ L2Regularization = 0, NumberOfIterations = 80})}; foreach (var trainer in trainers) { @@ -121,8 +121,8 @@ public void TestEstimatorHogwildSGD() [Fact] public void TestEstimatorHogwildSGDNonCalibrated() { - var trainers = new[] { ML.BinaryClassification.Trainers.StochasticGradientDescentNonCalibrated(loss : new SmoothedHingeLoss()), - ML.BinaryClassification.Trainers.StochasticGradientDescentNonCalibrated(new Trainers.SgdNonCalibratedBinaryTrainer.Options() { Loss = new HingeLoss() }) }; + var trainers = new[] { ML.BinaryClassification.Trainers.SgdNonCalibrated(loss : new SmoothedHingeLoss()), + ML.BinaryClassification.Trainers.SgdNonCalibrated(new Trainers.SgdNonCalibratedTrainer.Options() { Loss = new HingeLoss() }) }; foreach (var trainer in trainers) { diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs b/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs index 21d6eedf92..8cfb019da1 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/TreeEstimators.cs @@ -70,7 +70,7 @@ public void GAMClassificationEstimator() { var (pipe, dataView) = GetBinaryClassificationPipeline(); - var trainer = new BinaryClassificationGamTrainer(Env, new BinaryClassificationGamTrainer.Options + var trainer = new GamBinaryClassificationTrainer(Env, new GamBinaryClassificationTrainer.Options { GainConfidenceLevel = 0, NumberOfIterations = 15, @@ -90,7 +90,7 @@ public void FastForestClassificationEstimator() var (pipe, dataView) = GetBinaryClassificationPipeline(); var trainer = ML.BinaryClassification.Trainers.FastForest( - new FastForestClassification.Options + new FastForestBinaryClassificationTrainer.Options { NumberOfLeaves = 10, NumberOfTrees = 20, @@ -188,7 +188,7 @@ public void LightGBMRegressorEstimator() public void GAMRegressorEstimator() { var dataView = GetRegressionPipeline(); - var trainer = new RegressionGamTrainer(Env, new RegressionGamTrainer.Options + var trainer = new GamRegressionTrainer(Env, new GamRegressionTrainer.Options { EnablePruning = false, NumberOfIterations = 15, @@ -226,7 +226,7 @@ public void FastForestRegressorEstimator() { var dataView = GetRegressionPipeline(); var trainer = ML.Regression.Trainers.FastForest( - new FastForestRegression.Options + new FastForestRegressionTrainer.Options { BaggingSize = 2, NumberOfTrees = 10, @@ -294,7 +294,7 @@ private void LightGbmHelper(bool useSoftmax, out string modelString, out List