[Paper Review] Macro F1 and Macro F1
This paper identifies and analyzes two distinct formulas for computing macro F1: 'averaged F1' (arithmetic mean of class-wise F1 scores) and 'F1 of averages' (harmonic mean of class-averaged precision and recall). It proves that F1 of averages can be significantly higher—up to 0.5—than averaged F1 when error distributions are skewed, leading to divergent classifier rankings. The key contribution is exposing a critical ambiguity in macro F1 usage that can mislead model evaluation in imbalanced classification tasks.
The 'macro F1' metric is frequently used to evaluate binary, multi-class and multi-label classification problems. Yet, we find that there exist two different formulas to calculate this quantity. In this note, we show that only under rare circumstances the two computations can be considered equivalent. More specifically, one formula well 'rewards' classifiers which produce a skewed error type distribution. In fact, the difference in outcome of the two computations can be as high as 0.5. The two computations may not only diverge in their scalar result but can also lead to different classifier rankings.
Motivation & Objective
- To identify and clarify the existence of two conflicting formulas for computing macro F1 in classification evaluation.
- To analyze the mathematical conditions under which the two formulas diverge in their numerical outcomes.
- To demonstrate that the two metrics can rank classifiers differently, even when applied to the same model and dataset.
- To quantify the maximum possible difference between the two metrics and identify the error distribution patterns that maximize this difference.
- To warn researchers about the risk of misinterpretation and inconsistent conclusions when using macro F1 without specifying the underlying formula.
Proposed method
- Defining two distinct macro F1 formulations: 'averaged F1' as the arithmetic mean of harmonic F1 scores per class, and 'F1 of averages' as the harmonic mean of class-averaged precision and recall.
- Deriving a closed-form expression for the difference Δ = F1_of_averages − averaged_F1 using matrix-based precision and recall per class.
- Proving that Δ ≥ 0 always holds, and Δ > 0 if and only if at least one class has Pᵢ ≠ Rᵢ.
- Establishing the theoretical upper bound of Δ as 0.5 (when n is even) or 0.5 − 1/(2n²) (when n is odd), achieved under extreme error imbalance.
- Conducting numerical experiments on synthetic datasets with random classifiers to empirically validate the theoretical difference and classifier ranking discrepancies.
- Implementing a reference code to compute both metrics and their difference, enabling reproducibility and practical use.
Experimental results
Research questions
- RQ1Under what conditions do the two macro F1 formulas produce significantly different numerical results?
- RQ2Can the two macro F1 metrics lead to different rankings of classifiers when evaluated on the same dataset?
- RQ3What is the maximum possible difference between the two macro F1 formulations, and under what error distribution is this difference achieved?
- RQ4Why does the 'F1 of averages' formulation systematically favor classifiers with skewed error distributions?
- RQ5How do these differences manifest in real-world scenarios with imbalanced class distributions and random baselines?
Key findings
- The 'F1 of averages' metric can be up to 0.5 higher than 'averaged F1' when the number of classes is even and error distributions are maximally skewed.
- The difference Δ between the two metrics is strictly positive whenever any class has unequal precision and recall, i.e., Pᵢ ≠ Rᵢ.
- The two metrics can rank classifiers differently: a classifier biased toward certain error types may rank higher under 'F1 of averages' but lower under 'averaged F1'.
- In random classification tasks with imbalanced data (e.g., 95% vs. 5%), the 'F1 of averages' yields higher scores (up to ~0.56) than 'averaged F1' (~0.41), with a root mean square deviation of 0.13.
- The difference Δ is maximized when some classes have (P,R) ≈ (1,0) and others have (P,R) ≈ (0,1), leading to F1 ≈ 0 for averaged F1 but F1 ≈ 0.5 for F1 of averages.
- The implementation example shows a 0.485 difference in practice: for a confusion matrix with extreme imbalance, 'F1 of averages' gives 0.505 while 'averaged F1' gives only 0.0196.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.