Skip to content

Commit d932807

Browse files
author
Pete Luferenko
committed
Another rework of first example
1 parent 1e90463 commit d932807

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/Microsoft.ML.Tests/Scenarios/Api/AspirationalExamples.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ public void FirstExperienceWithML()
4040
// Concatenate all features into a vector.
4141
Features: row.SepalWidth.ConcatWith(row.SepalLength, row.PetalWidth, row.PetalLength)));
4242

43-
// Create a learner and train it.
44-
var learner = preprocess.AppendEstimator(row => row.Label.SdcaPredict(row.Features, l1Coefficient: 0.1));
45-
var classifier = learner.Fit(data);
43+
var pipeline = preprocess
44+
// Append the trainer to the training pipeline.
45+
.AppendEstimator(row => row.Label.PredictWithSdca(row.Features))
46+
.AppendEstimator(row => row.PredictedLabel.KeyToValue());
4647

47-
// Add another transformer that converts the integer prediction into string.
48-
var finalTransformer = classifier.AppendTransformer(row => row.PredictedLabel.KeyToValue());
48+
// Train the model and make some predictions.
49+
var model = pipeline.Fit<IrisExample, IrisPrediction>(data);
4950

50-
// Make a prediction engine and predict.
51-
engine = finalTransformer.MakePredictionEngine<IrisExample, IrisPrediction>();
52-
IrisPrediction prediction = engine.Predict(new IrisExample
51+
IrisPrediction prediction = model.Predict(new IrisExample
5352
{
5453
SepalWidth = 3.3f,
5554
SepalLength = 1.6f,

0 commit comments

Comments
 (0)