Exemple #1
0
        // load
        public ModelMLNet(string path)
        {
#if ML_LEGACY
            TrainedModel = PredictionModel.ReadAsync <ModelDataSet, ModelDataSetPrediction>(path).Result;
#else
            Context = new MLContext();

            // load
            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                TrainedModel = Context.Model.Load(stream);
            }

            // create the prediction function
            PredictFunc = TrainedModel.MakePredictionFunction <ModelDataSet, ModelDataSetPrediction>(Context);
#endif
        }
 public ITransformer Train(IDataView trainingData)
 {
     TrainedModel       = _trainingPipeline.Fit(trainingData);
     PredictionFunction = TrainedModel.MakePredictionFunction <DemandObservation, DemandPrediction>(_mlcontext);
     return(TrainedModel);
 }