The formula for F1 harmonic mean F1 score is

$$ F1 =2*\frac{precision*recall}{precision + recall} $$

enter image description here

The values under the column F1 don't agree with the formula. Any answers

  • $\begingroup$ Please provide your calculation. It seems everything is fine $\endgroup$ Jun 22 '18 at 6:39
  • $\begingroup$ Lets take the example of Logistic regression F1=2*(0.831*0.811)/(0.831+0.811)=0.8208. The value given under F1 is 0.788 $\endgroup$ Jun 22 '18 at 7:45
  • 2
    $\begingroup$ I had posted this question as a bug. It was address. The calculations are okay. The values that we see are the average of F1 for Y and N responses. $\endgroup$ Jun 27 '18 at 13:51
  • $\begingroup$ The same issue (reported scores is average of the class statistics) here: datascience.stackexchange.com/q/60850/55122 $\endgroup$ Oct 4 '19 at 21:06

It is not a bug just weighted averaging is used in computing F1, precision or recall. That means that score is computed per each label/class and then averaged. See the documention by sklearn.

In case of the classifier with 3 classes, the F1 score is computed for class 1 as a target class using the rule you wrote, class 2 as a target class and class 3 as a target class. Those scores are then averaged to retrieve the final score. Recall and precision are computed the same way, all of them are averaging over class scores. The rule you wrote is used in per class calculation but it does not hold for averages.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.