ML.NET チュートリアル | 概要を 10 分で
モデルを使用する
ML.NET CLI によって、トレーニング済みのモデルとコードが生成されたため、次の手順に従って、.NET アプリケーション (たとえば SentimentModel コンソール アプリ) でモデルを使用できるようになりました。
- コマンド ラインで、consumeModelAppディレクトリに移動します。Terminalcd SentimentModel
- 
            任意のコード エディターで Program.csを開き、コードを確認します。コードは次のようになります。Program.csusing 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(); } } }
- 
            SentimentModel.ConsoleAppを実行します。これを行うには、ターミナルで次のコマンドを実行します (SentimentModelディレクトリであることを確認してください)。Terminaldotnet run出力は次のようになります: TerminalUsing model to make single prediction -- Comparing actual Col1 with predicted Col1 from sample data... Col0: Wow... Loved this place. Col1: 1 Class Score ----- ----- 1 0.9651076 0 0.034892436 =============== End of process, hit any key to finish ===============
 
                        



![Machine Learning Model (ML.NET) が選択され、SentimentModel.mbconfig がファイル名として表示されている [新しい項目の追加] ダイアログ。](https://dotnet.microsoft.com/blob-assets/images/tutorials/machine-learning/new-item-mbconfig.png)
![Model Builder でサポートされているさまざまなシナリオを示すVisual Studio の [シナリオの選択] タブのスクリーンショット。](https://dotnet.microsoft.com/blob-assets/images/tutorials/machine-learning/model-builder-scenario.png)




 
    
 
        


