【发布时间】:2022-01-03 12:16:48
【问题描述】:
我正在关注一个教程,它给了我这个示例代码。我想更改它,以便用户通过控制台而不是在代码中输入数据,但我不确定如何,有什么想法吗?
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}");
【问题讨论】:
标签: c# machine-learning ml.net