首页 > 解决方案 > 在 ML.net 中显示“predictionEngine”

问题描述

我正在尝试在我的项目中使用 ML.net。我想显示 predictionEngine 列的值。但我不知道该怎么做, 这张图片显示了预测引擎的输出。

谁能帮我显示这些列??

MLContext mlContext = new MLContext();

        // Training code used by ML.NET CLI and AutoML to generate the model
        ModelBuilder.CreateModel();

        //Load the saved model into your application
        ITransformer mlModel = mlContext.Model.Load(GetAbsolutePath(MODEL_FILEPATH), out DataViewSchema inputSchema);
        var predEngine = mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);
        //Use the PredictionEngine to predict the Algorithm ModelInput label

        // Try a single prediction
        ModelOutput predictionResult = predEngine.Predict(Input);

        return predictionResult;

标签: c#.netml.net

解决方案


您可以将其添加到您的源代码中

 Console.WriteLine("Using model to make single prediction -- Comparing actual Spam with predicted Spam from sample data...\n\n");
            Console.WriteLine($"Message: {sampleData.Message}");
            Console.WriteLine($"\n\nActual Spam: {sampleData.Spam} \nPredicted Spam: {predictionResult.Prediction}\n\n");
            Console.WriteLine("=============== End of process, hit any key to finish ===============");
            Console.ReadKey();

推荐阅读