Skip to content

Commit ef416f7

Browse files
author
Pete Luferenko
committed
No need to give schema to prediction engine
1 parent 41df05a commit ef416f7

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void New_SimpleTrainAndPredict()
7878
var model = pipeline.Fit(new MultiFileSource(dataPath));
7979

8080
// Create prediction engine and test predictions.
81-
var engine = new MyPredictionEngine<SentimentData, SentimentPrediction>(env, model.Reader.GetOutputSchema(), model.Transformer);
81+
var engine = new MyPredictionEngine<SentimentData, SentimentPrediction>(env, model.Transformer);
8282

8383
// Take a couple examples out of the test data and run predictions on top.
8484
var testData = model.Reader.Read(new MultiFileSource(GetDataPath(SentimentTestPath)))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void New_TrainSaveModelAndPredict()
101101
}
102102

103103
// Create prediction engine and test predictions.
104-
var engine = new MyPredictionEngine<SentimentData, SentimentPrediction>(env, model.Reader.GetOutputSchema(), model.Transformer);
104+
var engine = new MyPredictionEngine<SentimentData, SentimentPrediction>(env, model.Transformer);
105105

106106
// Take a couple examples out of the test data and run predictions on top.
107107
var testData = model.Reader.Read(new MultiFileSource(GetDataPath(SentimentTestPath)))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void New_TrainWithInitialPredictor()
6969

7070
// Train the second predictor on the same data.
7171
var secondTrainer = new MyAveragedPerceptron(env, new AveragedPerceptronTrainer.Arguments(), "Features", "Label");
72-
var finalPredictor = secondTrainer.Train(trainData, firstPredictor);
72+
var finalPredictor = secondTrainer.Train(trainData, firstPredictor.Model);
7373
}
7474
}
7575

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ public MyAveragedPerceptron(IHostEnvironment env, AveragedPerceptronTrainer.Argu
313313

314314
protected override IPredictor TrainCore(TrainContext trainContext) => _trainer.Train(trainContext);
315315

316-
public ITransformer Train(IDataView trainData, IPredictorTransformer<IPredictor> initialPredictor)
316+
public ITransformer Train(IDataView trainData, IPredictor initialPredictor)
317317
{
318-
return TrainTransformer(trainData, initPredictor: initialPredictor.TrainedModel);
318+
return TrainTransformer(trainData, initPredictor: initialPredictor);
319319
}
320320
}
321321

@@ -325,9 +325,9 @@ public sealed class MyPredictionEngine<TSrc, TDst>
325325
{
326326
private readonly PredictionEngine<TSrc, TDst> _engine;
327327

328-
public MyPredictionEngine(IHostEnvironment env, ISchema inputSchema, ITransformer pipe)
328+
public MyPredictionEngine(IHostEnvironment env, ITransformer pipe)
329329
{
330-
IDataView dv = new EmptyDataView(env, inputSchema);
330+
IDataView dv = env.CreateDataView(new TSrc[0]);
331331
_engine = env.CreatePredictionEngine<TSrc, TDst>(pipe.Transform(dv));
332332
}
333333

0 commit comments

Comments
 (0)