@@ -119,20 +119,21 @@ public static void Evaluate(MLContext mlContext, ITransformer model, IDataView s
119119 // The Accuracy metric gets the accuracy of a model, which is the proportion
120120 // of correct predictions in the test set.
121121
122- // The AreaUnderRocCurve metric is an indicator of how confident the model is
123- // correctly classifying the positive and negative classes as such.
122+ // The AreaUnderROCCurve metric is equal to the probability that the algorithm ranks
123+ // a randomly chosen positive instance higher than a randomly chosen negative one
124+ // (assuming 'positive' ranks higher than 'negative').
124125
125126 // The F1Score metric gets the model's F1 score.
126- // F1 is a measure of tradeoff between precision and recall.
127+ // The F1 score is the harmonic mean of precision and recall:
127128 // 2 * precision * recall / (precision + recall).
128129
129130 // <SnippetDisplayMetrics>
130131 Console . WriteLine ( ) ;
131132 Console . WriteLine ( "Model quality metrics evaluation" ) ;
132133 Console . WriteLine ( "--------------------------------" ) ;
133- Console . WriteLine ( $ " Accuracy: { metrics . Accuracy : P2} ") ;
134- Console . WriteLine ( $ "Area Under Roc Curve : { metrics . AreaUnderRocCurve : P2} ") ;
135- Console . WriteLine ( $ " F1Score: { metrics . F1Score : P2} ") ;
134+ Console . WriteLine ( $ "Accuracy: { metrics . Accuracy : P2} ") ;
135+ Console . WriteLine ( $ "Auc : { metrics . AreaUnderRocCurve : P2} ") ;
136+ Console . WriteLine ( $ "F1Score: { metrics . F1Score : P2} ") ;
136137 Console . WriteLine ( "=============== End of model evaluation ===============" ) ;
137138 //</SnippetDisplayMetrics>
138139
@@ -159,7 +160,7 @@ private static void UseModelWithSingleItem(MLContext mlContext, ITransformer mod
159160 Console . WriteLine ( "=============== Prediction Test of model with a single sample and test dataset ===============" ) ;
160161
161162 Console . WriteLine ( ) ;
162- Console . WriteLine ( $ "Sentiment: { sampleStatement . SentimentText } | Prediction: { ( Convert . ToBoolean ( resultprediction . Prediction ) ? "Positive" : "Negative" ) } | Probability: { resultprediction . Probability } ") ;
163+ Console . WriteLine ( $ "Sentiment: { resultprediction . SentimentText } | Prediction: { ( Convert . ToBoolean ( resultprediction . Prediction ) ? "Positive" : "Negative" ) } | Probability: { resultprediction . Probability } ") ;
163164
164165 Console . WriteLine ( "=============== End of Predictions ===============" ) ;
165166 Console . WriteLine ( ) ;
@@ -200,20 +201,15 @@ public static void UseModelWithBatchItems(MLContext mlContext, ITransformer mode
200201 // </SnippetAddInfoMessage>
201202
202203 Console . WriteLine ( ) ;
203-
204- // Builds pairs of (sentiment, prediction)
205- // <SnippetBuildSentimentPredictionPairs>
206- IEnumerable < ( SentimentData sentiment , SentimentPrediction prediction ) > sentimentsAndPredictions = sentiments . Zip ( predictedResults , ( sentiment , prediction ) => ( sentiment , prediction ) ) ;
207- // </SnippetBuildSentimentPredictionPairs>
208-
204+
209205 // <SnippetDisplayResults>
210- foreach ( ( SentimentData sentiment , SentimentPrediction prediction ) item in sentimentsAndPredictions )
206+ foreach ( SentimentPrediction prediction in predictedResults )
211207 {
212- Console . WriteLine ( $ "Sentiment: { item . sentiment . SentimentText } | Prediction: { ( Convert . ToBoolean ( item . prediction . Prediction ) ? "Positive" : "Negative" ) } | Probability: { item . prediction . Probability } ") ;
208+ Console . WriteLine ( $ "Sentiment: { prediction . SentimentText } | Prediction: { ( Convert . ToBoolean ( prediction . Prediction ) ? "Positive" : "Negative" ) } | Probability: { prediction . Probability } ") ;
213209
214210 }
215211 Console . WriteLine ( "=============== End of predictions ===============" ) ;
216- // </SnippetDisplayResults>
212+ // </SnippetDisplayResults>
217213 }
218214
219215 }
0 commit comments