@@ -15,12 +15,11 @@ public class AutoTrainBinaryClassification
1515 private static string TrainDataPath = $ "{ BaseDatasetsLocation } /wikipedia-detox-250-line-data.tsv";
1616 private static string TestDataPath = $ "{ BaseDatasetsLocation } /wikipedia-detox-250-line-test.tsv";
1717 private static string ModelPath = $ "{ BaseDatasetsLocation } /SentimentModel.zip";
18- private static string LabelColumnName = "Label " ;
18+ private static string LabelColumnName = "Sentiment " ;
1919
2020 public static void Run ( )
2121 {
22- //Create ML Context with seed for repeteable/deterministic results
23- MLContext mlContext = new MLContext ( seed : 0 ) ;
22+ MLContext mlContext = new MLContext ( ) ;
2423
2524 // STEP 1: Infer columns
2625 var columnInference = mlContext . Data . InferColumns ( TrainDataPath , LabelColumnName , '\t ' ) ;
@@ -32,16 +31,16 @@ public static void Run()
3231
3332 // STEP 3: Auto featurize, auto train and auto hyperparameter tuning
3433 Console . WriteLine ( $ "Invoking BinaryClassification.AutoFit") ;
35- var autoFitResults = mlContext . BinaryClassification . AutoFit ( trainDataView , timeoutInSeconds : 60 ) ;
34+ var autoFitResults = mlContext . BinaryClassification . AutoFit ( trainDataView , LabelColumnName , timeoutInSeconds : 60 ) ;
3635
3736 // STEP 4: Print metric from the best model
3837 var best = autoFitResults . Best ( ) ;
39- Console . WriteLine ( $ "Accuracy of best model from validation data { best . Metrics . Accuracy } ") ;
38+ Console . WriteLine ( $ "Accuracy of best model from validation data: { best . Metrics . Accuracy } ") ;
4039
4140 // STEP 5: Evaluate test data
4241 IDataView testDataViewWithBestScore = best . Model . Transform ( testDataView ) ;
43- var testMetrics = mlContext . Regression . Evaluate ( testDataViewWithBestScore , label : DefaultColumnNames . Label , DefaultColumnNames . Score ) ;
44- Console . WriteLine ( $ "Accuracy of best model from test data { best . Metrics . Accuracy } ") ;
42+ var testMetrics = mlContext . BinaryClassification . EvaluateNonCalibrated ( testDataViewWithBestScore , label : LabelColumnName , DefaultColumnNames . Score ) ;
43+ Console . WriteLine ( $ "Accuracy of best model from test data: { best . Metrics . Accuracy } ") ;
4544
4645 // STEP 6: Save the best model for later deployment and inferencing
4746 using ( var fs = File . Create ( ModelPath ) )
0 commit comments