Formula
F1 = 2 × precision × recall ÷ (precision + recall)F1 = 2TP ÷ (2TP + FP + FN)Why a harmonic mean
Take a model with precision 0.9 and recall 0.6. The arithmetic mean would be 0.75. F1 gives 2 × 0.9 × 0.6 ÷ 1.5 = 0.72, and the gap widens as the two drift apart: at precision 1.0 and recall 0.1, F1 is about 0.18. A model cannot buy a good F1 by maximizing one side and neglecting the other.
Weighting recall or precision: F-beta
Fβ = (1 + β²) × precision × recall ÷ (β² × precision + recall)Traps
- F1 depends on the confidence threshold. Quote the threshold with the number, or compare models with a threshold-free metric such as mean average precision.
- Macro F1 averages classes equally, micro F1 pools all counts. On imbalanced data the two can tell opposite stories.
- In detection, a prediction counts as a true positive only above an IoU threshold, so F1 at IoU 0.5 and at 0.75 are different numbers.
For two sets of pixels, F1 equals the Dice coefficient: both are 2TP ÷ (2TP + FP + FN).
F1 in Supervisely
The model evaluation report for detection and instance segmentation lists F1 next to precision and recall, with per-class metrics and the best confidence threshold for the model, so the number a team quotes matches the setting they deploy.