Calculating F1 from Precision and Recall
F1 is the harmonic mean of positive precision and recall under the specified convention, so a low value of either lowers the score.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace two rates
If precision is 0.75 and recall 0.60, \(2(0.75)(0.60)/(0.75+0.60)=2/3\). Here the harmonic mean lies between 0.60 and 0.75. This combines precision and recall.
Keep original counts
Several confusion matrices can have the same F1. Report their component counts when decision costs differ or when comparing groups. Define how cases of zero denominators are represented.[1][2]
Compute the harmonic mean with visible counts
With six true positives, two false positives and six false negatives, precision is 0.75 and recall is 0.5. Their harmonic mean is \(2(0.75)(0.5)/(0.75+0.5)=0.6\). See precision and recall.
Count formula: 2TP ÷ (2TP+FP+FN)
Values give 12 ÷ (12+2+6)=.6
Arithmetic mean of the two rates would be .625
Report what F1 leaves out
True negatives do not affect this binary calculation with the other counts fixed. Report relevant error tradeoffs and the threshold. Handle zero denominators explicitly when no positive examples and no positive predictions exist.