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 ===============