Skip to content

Commit 8a8ea7e

Browse files
committed
Fix SDCA sample runtime exception. (dotnet#3259)
* Fix SDCA sample runtime exception. * PR feedback. * More fixes.
1 parent 1cdc47a commit 8a8ea7e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/StochasticDualCoordinateAscent.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public static void Example()
4747
// Featurize the text column through the FeaturizeText API.
4848
// Then append a binary classifier, setting the "Label" column as the label of the dataset, and
4949
// the "Features" column produced by FeaturizeText as the features column.
50-
var pipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features")
50+
var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText")
5151
.AppendCacheCheckpoint(mlContext) // Add a data-cache step within a pipeline.
52-
.Append(mlContext.BinaryClassification.Trainers.SdcaNonCalibrated(labelColumnName: "Sentiment", featureColumnName: "Features", l2Regularization: 0.001f));
52+
.Append(mlContext.BinaryClassification.Trainers.SdcaLogisticRegression(labelColumnName: "Sentiment", featureColumnName: "Features", l2Regularization: 0.001f));
5353

5454
// Step 3: Run Cross-Validation on this pipeline.
5555
var cvResults = mlContext.BinaryClassification.CrossValidate(data, pipeline, labelColumnName: "Sentiment");
@@ -59,7 +59,7 @@ public static void Example()
5959

6060
// If we wanted to specify more advanced parameters for the algorithm,
6161
// we could do so by tweaking the 'advancedSetting'.
62-
var advancedPipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features")
62+
var advancedPipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText")
6363
.Append(mlContext.BinaryClassification.Trainers.SdcaLogisticRegression(
6464
new SdcaLogisticRegressionBinaryTrainer.Options {
6565
LabelColumnName = "Sentiment",
@@ -69,7 +69,7 @@ public static void Example()
6969
}));
7070

7171
// Run Cross-Validation on this second pipeline.
72-
var cvResults_advancedPipeline = mlContext.BinaryClassification.CrossValidate(data, pipeline, labelColumnName: "Sentiment", numberOfFolds: 3);
72+
var cvResults_advancedPipeline = mlContext.BinaryClassification.CrossValidate(data, advancedPipeline, labelColumnName: "Sentiment", numberOfFolds: 3);
7373
accuracies = cvResults_advancedPipeline.Select(r => r.Metrics.Accuracy);
7474
Console.WriteLine(accuracies.Average());
7575

0 commit comments

Comments
 (0)