- Hands-On Machine Learning with ML.NET
- Jarred Capellman
- 121字
- 2021-06-24 16:43:34
The Predictor class
The Predictor class, much like what was changed in the linear regression example, is simply modified to support the new model and return the classification:
- We begin by passing in the two new classes, FileInput and FilePrediction, to the CreatePredictionEngine method:
var predictionEngine = MlContext.Model.CreatePredictionEngine<FileInput, FilePrediction>(mlModel);
- Next, we create the FileInput object, setting the Strings property with the return value of the GetStrings method we wrote earlier:
var prediction = predictionEngine.Predict(new FileInput
{
Strings = GetStrings(File.ReadAllBytes(inputDataFile))
});
- Finally, we update the output call to the Console object with our file classification and probability:
Console.WriteLine(
$"Based on the file ({inputDataFile}) the file is classified as {(prediction.IsMalicious ? "malicious" : "benign")}" +
$" at a confidence level of {prediction.Probability:P0}");
推薦閱讀
- Node.js Design Patterns
- CockroachDB權威指南
- HTML5+CSS3網站設計基礎教程
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Reactive Android Programming
- Learning Hunk
- Learning ArcGIS for Desktop
- 單片機C語言程序設計實訓100例
- 西門子S7-200 SMART PLC編程從入門到實踐
- Internet of Things with ESP8266
- Visual Basic程序設計習題與上機實踐
- Spring Security Essentials
- Puppet:Mastering Infrastructure Automation
- 你好!Java
- Mastering Machine Learning with R