Esempio n. 1
0
        private static void TestSomePredictions(MLContext mlContext)
        {
            //Test Classification Predictions with some hard-coded samples

            var modelScorer = new Common.ModelScorer <IrisData, IrisPrediction>(mlContext);

            modelScorer.LoadModelFromZipFile(ModelPath);

            var prediction = modelScorer.PredictSingle(SampleIrisData.Iris1);

            Console.WriteLine($"Actual: setosa.     Predicted probability: setosa:      {prediction.Score[0]:0.####}");
            Console.WriteLine($"                                           versicolor:  {prediction.Score[1]:0.####}");
            Console.WriteLine($"                                           virginica:   {prediction.Score[2]:0.####}");
            Console.WriteLine();

            prediction = modelScorer.PredictSingle(SampleIrisData.Iris2);
            Console.WriteLine($"Actual: virginica.  Predicted probability: setosa:      {prediction.Score[0]:0.####}");
            Console.WriteLine($"                                           versicolor:  {prediction.Score[1]:0.####}");
            Console.WriteLine($"                                           virginica:   {prediction.Score[2]:0.####}");
            Console.WriteLine();

            prediction = modelScorer.PredictSingle(SampleIrisData.Iris3);
            Console.WriteLine($"Actual: versicolor. Predicted probability: setosa:      {prediction.Score[0]:0.####}");
            Console.WriteLine($"                                           versicolor:  {prediction.Score[1]:0.####}");
            Console.WriteLine($"                                           virginica:   {prediction.Score[2]:0.####}");
            Console.WriteLine();
        }
Esempio n. 2
0
        public static void Predict(MLContext mlContext, ITransformer model)
        {
            //Test Classification Predictions with some hard-coded samples

            var modelScorer = new Common.ModelScorer <IrisData, IrisPrediction>(mlContext, model);
            var prediction  = modelScorer.PredictSingle(SampleIrisData.Iris1);
        }