-
Book Overview & Buying
-
Table Of Contents
Practical C# Projects with .NET
By :
Just as we needed a StudentData class to represent rows from our data file, we also need to define a class to represent our model's predictions.
Since predictions are far simpler than the source data, we can get by with a class with a single property mapped to the Score column from the ML.NET model trainer's output:
public class StudentPrediction {
[ColumnName("Score")]
public float PredictedValue { get; set; }
}
With this class, we will be able to reference the PredictedValue property on a StudentPrediction object, and it should map to the value that our trained model produces for that piece of data.
This actual prediction process is managed through a PredictionEngine object, which takes in the ITransformer variable as well as both the type of each data row and the type of the prediction output as generic type parameters:
PredictionEngine<StudentData, StudentPrediction> predictionEngine =
context.Model...