-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (32 loc) · 1.35 KB
/
Program.cs
File metadata and controls
41 lines (32 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using SampleBinaryClassification.Model.DataModels;
using Microsoft.ML;
namespace consumeModelApp
{
class Program
{
static void Main(string[] args)
{
ConsumeModel();
}
public static void ConsumeModel()
{
// Load the model
MLContext mlContext = new MLContext();
ITransformer mlModel = mlContext.Model.Load("MLModel.zip", out var modelInputSchema);
var predEngine = mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Please enter the text to be judged for toxic sentiment:");
Console.ForegroundColor = ConsoleColor.White;
string InputLineToJudge = Console.ReadLine();
// Use the code below to add input data
var input = new ModelInput();
input.SentimentText = InputLineToJudge;
// Try model on sample data
// True is toxic, false is non-toxic
ModelOutput result = predEngine.Predict(input);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine($"Prediction: {(Convert.ToBoolean(result.Prediction) ? "Toxic" : "Non Toxic")} sentiment");
}
}
}