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

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}");
主站蜘蛛池模板: 广东省| 利津县| 福海县| 阿克陶县| 德化县| 东乌| 顺昌县| 昌江| 安庆市| 克拉玛依市| 淳化县| 松原市| 金寨县| 电白县| 揭西县| 类乌齐县| 连南| 镇巴县| 贺兰县| 木兰县| 玉田县| 通化县| 寻甸| 沛县| 博乐市| 普兰县| 驻马店市| 定陶县| 饶阳县| 都匀市| 连云港市| 鄂伦春自治旗| 宁国市| 东城区| 洪雅县| 巴林左旗| 扎兰屯市| 平远县| 株洲市| 彰化县| 玉环县|