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

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}");
主站蜘蛛池模板: 镇远县| 罗城| 阜新市| 丘北县| 旺苍县| 尉氏县| 灵璧县| 嘉义县| 纳雍县| 满城县| 黄平县| 友谊县| 北海市| 康马县| 福贡县| 唐河县| 双流县| 黄平县| 大港区| 井冈山市| 河北省| 乌拉特前旗| 双辽市| 珠海市| 辰溪县| 巴东县| 博爱县| 溆浦县| 界首市| 安达市| 临湘市| 屏南县| 桃园市| 壤塘县| 竹山县| 铅山县| 东安县| 巍山| 泾阳县| 广饶县| 岳普湖县|