- Introduced by
- Multi-class evaluation community
- Year
- 2000s
- Type
- Evaluation metric
- Family
- Classification Metric
What does it do?
Macro-averaged F1 computes an F1-score separately for each class and then takes the unweighted mean across classes.
Every class counts equally regardless of how many samples it has, so performance on rare classes carries the same weight as performance on frequent ones. It is used for multi-class problems where every class matters to the task. It is most natural when class sizes are roughly similar, and it remains a deliberate choice when sizes differ but each class is judged equally important.
The intuition behind the method
Metrics that pool all predictions together are dominated by the most frequent class, because its samples make up most of the counts. Macro-averaging avoids this by scoring each class on its own and then averaging those scores with equal weight. A weak F1-score on a rare class therefore lowers the macro average as much as a weak score on a common class would, which is the appropriate behaviour when every class matters to the application.
History
A 2017 machine learning textbook presents macro-averaging as the simplest way of aggregating performance across classes: the criterion is computed for each class separately, and the arithmetic mean of those values is taken, so each class is weighted equally. Sokolova, Japkowicz and Szpakowicz (2006) extend performance evaluation beyond accuracy, F-score and ROC toward a family of discriminant measures.
When to use it
Choose macro-averaged F1 for multi-class classification when every class should count equally in the evaluation. It is most natural when class sizes are roughly similar. When class sizes are unequal, use it only if each class is judged equally important for the application, and treat this as an explicit weighting decision, since rare classes then carry as much influence on the score as frequent ones. It suits evaluations that should reflect average per-class performance rather than per-sample performance. Do not use it when only one class is of interest; report that class's F1-score directly. It is also a poor fit when class frequencies themselves reflect real importance, because equal weighting then gives rare classes more influence than they warrant; a frequency-weighted or pooled measure may suit better. Report it together with accuracy and per-class scores rather than in place of them.
Limitations and considerations
- Per-class F1-scores for rare classes are unstable, so the macro average can move substantially when a few predictions change.
- The mean ignores class sizes entirely, so a class with a handful of samples and a class with many thousands carry identical weight.
- Each class's F1-score treats false positives and false negatives symmetrically and does not show which error type dominates, so it cannot tell whether a weak class is over-predicted or under-predicted.
- A class that is intrinsically hard to separate lowers the average even when the model performs as well as the data allow, so the score does not isolate model quality.
- When a class never appears in the predictions or the labels, its per-class F1-score is undefined; implementations differ in whether they report zero, skip the class or exclude it, and this changes the macro average.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Gives each class the same weight, so a majority class cannot dominate the score through sample count alone.
- Falls noticeably when any single class is handled poorly, because each class's F1-score enters the mean directly.
- Easy to explain: it is the arithmetic mean of per-class F1-scores that are usually reported anyway.
- Applies directly to multi-class problems without choosing one positive class.
Applications
- Multi-class text classification with rare topics: macro F1 weights each topic equally, so weak performance on a rare topic lowers the score, and the per-class scores show which topics fail.
- Diagnosis among many conditions, some of them rare: macro F1 weights each condition equally, so poor performance on a rare condition is visible in the score; per-class scores identify the affected conditions.
- Multi-class image classification on an imbalanced dataset: because each class carries equal weight, a model that performs well only on frequent classes will score lower than under a pooled measure.
- Language identification with minority languages: equal class weighting makes poor accuracy on minority languages visible in the average, and per-class scores show which languages are affected.
How it works
How it works
For each class, treat it as the positive class and all other classes together as negative. Count the true positives, false positives and false negatives for that class, and compute its F1-score as the harmonic mean of precision and recall.
Formula
Pr_i = \frac{TP_i}{TP_i + FP_i}, \quad Re_i = \frac{TP_i}{TP_i + FN_i}, \quad F1_i = \frac{2\,Pr_i\,Re_i}{Pr_i + Re_i}Average the per-class F1-scores with equal weight: macro F1 = (F1_class1 + F1_class2 + ... + F1_classN) / N, where N is the number of classes.
Formula
F1_{\text{macro}} = \frac{1}{L}\sum_{i=1}^{L} F1_iThe value lies between 0 and 1, and higher values indicate better balanced performance across classes. Because it is a plain mean, a low value implies at least one class with a low F1-score, but a moderate value can hide a single very poor class, so the per-class scores should be inspected alongside it.
Common pitfalls
- Reading only the macro value: a high average can conceal a very poor F1-score on one class, so per-class scores should always be reported next to it.
- Comparing macro F1 across datasets with different class distributions: the average depends on the class mix and the number of classes, so differences may reflect the dataset rather than the model.
- Treating a single split's macro F1 as precise: with rare classes its variance can be large, so compare models using repeated or stratified resampling and report the spread.
Frequently asked questions
When should I use macro-averaged F1 instead of micro-averaged F1?
Use macro-averaged F1 when every class should count equally in the evaluation. It is most natural when class sizes are roughly similar. If class sizes are unequal, it remains appropriate when each class is judged equally important, because it gives a rare class the same weight as a common one. Micro-averaging averages over all examples, so frequent classes dominate it; it suits settings where overall per-example performance is the goal. Whether class frequency reflects importance in your application determines the better choice.
Why can macro-averaged F1 be unstable for rare classes?
Rare classes have few samples, so their F1-scores can fluctuate based on small changes in a few predictions. A single classification error on a rare class has a large effect on that class's F1-score and thus on the macro average. Stratified cross-validation helps stabilize estimates.
Can macro-averaged F1 be low while accuracy is high?
Yes, this is the typical pattern in severely imbalanced data. Suppose class A is 99% of the data and classes B and C are 0.5% each. A model that predicts class A for every sample achieves high accuracy, but classes B and C have zero F1-score, so macro F1 is low. The metric reports this failure, which is the intended behaviour when the minority classes matter. The reverse pattern, high macro F1 with low accuracy, is possible but less typical, because it requires poor performance on the majority class while the minority classes are predicted well.
Related methods
Sources
Powers, D. M. (2011). Evaluation: From Precision, Recall and F-Measure to ROC, Informedness, Markedness and Correlation. Journal of Machine Learning Technologies, 2(1), 37-63.
Open publication referenceSokolova, M., Japkowicz, N., & Szpakowicz, S. (2006). Beyond Accuracy, F-Score and ROC: a Family of Discriminant Measures for Performance Evaluation. AI 2006, 4013, 1015-1021.
Open DOI reference2017_Book_AnIntroductionToMachineLearnin, p. 266