using MyMLApp;// Add input datavar sampleData = new SentimentModel.ModelInput()
{ Col0 = "This restaurant was wonderful."};// Load model and predict output of sample datavar result = SentimentModel.Predict(sampleData);// If Prediction is 1, sentiment is "Positive"; otherwise, sentiment is "Negative"var sentiment = result.PredictedLabel == 1 ? "Positive" : "Negative";Console.WriteLine($"Text: {sampleData.Col0}\nSentiment: {sentiment}");
using System;namespace SentimentModel.ConsoleApp{ class Program { static void Main(string[] args) { // Add input data SentimentModel.ModelInput sampleData = new SentimentModel.ModelInput() { Col0 = @"Wow... Loved this place." }; // Make a single prediction on the sample data and print results
var predictionResult = SentimentModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Col1 with predicted Col1 from sample data...\n\n"); Console.WriteLine($"Col0: @{"Wow... Loved this place."}"); Console.WriteLine($"Col1: {1F}"); Console.WriteLine($"\n\nPredicted Col1: {predictionResult.PredictedLabel}\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); } }}
Using model to make single prediction -- Comparing actual Col1 with predicted Col1 from sample data...Col0: Wow... Loved this place.Col1: 1Predicted Col1: 1=============== End of process, hit any key to finish ===============
次の手順
おめでとうございます。ML.NET Model Builder を使用して、最初の機械学習モデルを構築しました。