官术网_书友最值得收藏!

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:

  1. We begin by passing in the two new classes, FileInput and FilePrediction, to the CreatePredictionEngine method:
var predictionEngine = MlContext.Model.CreatePredictionEngine<FileInput, FilePrediction>(mlModel);
  1. 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))
});
  1. 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}");
主站蜘蛛池模板: 岑巩县| 通渭县| 云梦县| 鄂尔多斯市| 邢台县| 高邮市| 枞阳县| 福建省| 罗田县| 安图县| 会泽县| 宣汉县| 浏阳市| 长汀县| 霍邱县| 科技| 民勤县| 县级市| 平安县| 桐城市| 嘉义县| 万年县| 方山县| 于田县| 嘉善县| 三都| 象山县| 子长县| 富顺县| 阿拉善右旗| 陕西省| 恩平市| 陕西省| 大同市| 海宁市| 黑龙江省| 无棣县| 太和县| 巨鹿县| 丰镇市| 丰宁|