public void TrainAndWrite() { var pipeLine = new LearningPipeline(); pipeLine.Add(new Microsoft.ML.Legacy.Data.TextLoader("path").CreateFrom(useHeader: true, separator: ',')); pipeLine.Add(new CategoricalHashOneHotVectorizer(("UserId", "UserId"))); pipeLine.Add(new CategoricalHashOneHotVectorizer(("MovieId", "MovieId"))); pipeLine.Add(new ColumnConcatenator("Features", "UserId", "MovieId")); pipeLine.Add(new FieldAwareFactorizationMachineBinaryClassifier()); var model = pipeLine.Train(); model.WriteAsync(@"path../../Model.zip"); ReadAndEvaluate(model); } public void ReadAndEvaluate(PredictionModel model) { var testData = new Microsoft.ML.Legacy.Data.TextLoader("").CreateFrom(useHeader: true, separator: ','); model = PredictionModel.ReadAsync(@"path../../Model.zip").Result; var alogEvalutate = new BinaryClassifierEvaluator(); alogEvalutate.Evaluate(model, testData); Predict(model); } public void Predict(PredictionModel model) { model.Predict(new InputDetails()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)