コード例 #1
0
ファイル: Program.cs プロジェクト: ttom921/MachineLearning
        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();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ttom921/MachineLearning
        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);
        }