Below is my coding for Program.cs:
static void Main(string[] args)
{
//testing file location
string filepath = @"C:\Users\Desktop\Validation_Dataset - ColumnRename.csv";
CsvConfiguration config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
PrepareHeaderForMatch = args => args.Header.ToLower(),
MissingFieldFound = null
};
int correct = 0;
int total = 0;
using (var reader = new StreamReader(filepath))
using (var csv = new CsvReader(reader, config))
{
csv.Context.RegisterClassMap<PredictionDetailPredictMap>();
var records = csv.GetRecords<TrainTest.MLModel1.ModelInput>();
StringBuilder sb = new StringBuilder();
sb.Append("No,Expected,Predicted,IsMatch");
sb.AppendLine();
foreach (var record in records)
{
try
{
if (record.GB == "0") continue;
total++;
var result = TrainTest.MLModel1.Predict(record);
Console.WriteLine(record.No);
Console.WriteLine("Expected:" + record.GB);
Console.WriteLine("Predicted:" + result.PredictedLabel);
Console.WriteLine("====================");
//if (record.BinRootCause.ToLower() == result.Prediction.ToLower()) correct++;
string isMatch = record.GB.ToLower() == result.PredictedLabel.ToLower() ? "YES" : "NO";
if (isMatch == "YES") correct++;
sb.Append(record.No + "," + record.GB + "," + result.PredictedLabel + "," + isMatch + ",");
sb.AppendLine();
}
catch (Exception ex)
{
//store output file path
Console.WriteLine(ex.Message);
File.WriteAllText(@"C:\Desktop\Result\Testing.csv", sb.ToString());
}
}
sb.Append("Accuracy =" + ((float)correct / (float)total) * 100 + "%");
File.WriteAllText(@"C:\Desktop\Result\Testing.csv", sb.ToString());
Console.WriteLine("Accuracy=" + ((float)correct / (float)total) * 100 + "%");
}
}
Here is my sample output:
I looking for each cell/row have probability behind, for example:
Do you know how to get the probability for each prediction result?
Thanks.