我正在學習一個教程,它給了我這個示例代碼。我想改變它,以便用戶通過控制臺而不是代碼輸入資料,但我不確定如何,有什么想法嗎?
using MyMLApp;
// Add input data
var sampleData = new SentimentModel.ModelInput()
{
Col0 = "Will never go here again!"
};
// Load model and predict output of sample data
var result = SentimentModel.Predict(sampleData);
// If Prediction is 1, sentiment is "Positive"; otherwise, sentiment is "Negative"
string sentiment = result.Prediction == 1 ? "Positive" : "Negative";
Console.WriteLine($"Text: {sampleData.Col0}\nSentiment: {sentiment}");
uj5u.com熱心網友回復:
使用 Console.ReadLine()。可選擇處理代碼中的空輸入。
string? input = Console.ReadLine();
var sampleData = new SentimentModel.ModelInput()
{
Col0 = input
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/402886.html
標籤:
上一篇:KNN演算法的準確率很低
下一篇:我怎樣才能洗掉低相關的特征
