@@ -19,27 +19,28 @@ public static void Example()
19
19
var data = SamplesUtils . DatasetUtils . LoadFeaturizedAdultDataset ( mlContext ) ;
20
20
21
21
// Leave out 10% of data for testing
22
- var ( trainData , testData ) = mlContext . BinaryClassification . TrainTestSplit ( data , testFraction : 0.1 ) ;
22
+ var trainTestData = mlContext . BinaryClassification . TrainTestSplit ( data , testFraction : 0.1 ) ;
23
23
24
24
// Create data training pipeline
25
- var pipeline = mlContext . BinaryClassification . Trainers . AveragedPerceptron ( "IsOver50K" , "Features" ) ;
25
+ var pipeline = mlContext . BinaryClassification . Trainers . AveragedPerceptron (
26
+ "IsOver50K" , "Features" , numIterations : 10 ) ;
26
27
27
28
// Fit this pipeline to the training data
28
- var model = pipeline . Fit ( trainData ) ;
29
+ var model = pipeline . Fit ( trainTestData . TrainSet ) ;
29
30
30
31
// Evaluate how the model is doing on the test data
31
- var dataWithPredictions = model . Transform ( testData ) ;
32
+ var dataWithPredictions = model . Transform ( trainTestData . TestSet ) ;
32
33
var metrics = mlContext . BinaryClassification . EvaluateNonCalibrated ( dataWithPredictions , "IsOver50K" ) ;
33
34
SamplesUtils . ConsoleUtils . PrintMetrics ( metrics ) ;
34
35
35
36
// Output:
36
- // Accuracy: 0.85
37
- // AUC: 0.90
38
- // F1 Score: 0.66
39
- // Negative Precision: 0.89
37
+ // Accuracy: 0.86
38
+ // AUC: 0.91
39
+ // F1 Score: 0.68
40
+ // Negative Precision: 0.90
40
41
// Negative Recall: 0.91
41
- // Positive Precision: 0.69
42
- // Positive Recall: 0.63
42
+ // Positive Precision: 0.70
43
+ // Positive Recall: 0.66
43
44
}
44
45
}
45
46
}
0 commit comments