AI Glossary / Retrieval and knowledge systems / Intermediate
Macroaveraging
Definition
Macroaveraging combines evaluation results by calculating a metric separately for each class or other defined unit and then taking their unweighted arithmetic mean. In classification, each included class contributes equally to the final average, regardless of how many examples it contains. The metric and averaging units must be stated explicitly.
What it means
A model can perform well on a common category while failing on a rare one. An overall score dominated by common examples may conceal that imbalance. Macroaveraging gives each category an equal place in the summary, making poor performance on a small category more visible.
Equal contribution does not mean equal reliability. A score based on very few examples can be unstable, yet it has the same weight in the macro average as a score based on many examples. The average should therefore be accompanied by per-class results and sample counts.
How it works
Choose the metric and the set of classes to include. Compute each class's precision, recall or F-score using a consistent one-versus-rest interpretation where appropriate. Add the per-class values and divide by the number of included classes.
For macro F1 in the usual scikit-learn convention, first calculate F1 for every class and then average those F1 values. Taking the harmonic mean of macro precision and macro recall is generally a different calculation.
Define how absent classes and zero denominators are handled. Changing which classes are included can change the result even when the predictions stay the same. Macroaveraging also appears in other evaluations, such as averaging over queries, so the word macro alone does not identify the complete calculation.
Three practical examples
1. A document classifier reports macro F1 to show performance across both common and specialized subject categories.
2. A multilingual evaluation averages a metric equally across selected languages, explicitly identifying language rather than class as the averaging unit.
3. A support-routing model compares per-category recall and its macro average so that a small but important issue type is not hidden by high-volume routine requests.
Think of it this way
Think of giving each department one equal vote in a performance summary, even if their workloads differ. This answers how the departments perform on average, not what happened to the average individual request. Both views can be useful, but they describe different things and should not be presented as interchangeable.
Worked example
Consider an invented single-label classification test with 100 examples. Ninety truly belong to A and ten to B. The model correctly predicts A for 80 of the A examples and incorrectly predicts B for the other ten. It correctly predicts B for five B examples and incorrectly predicts A for the other five.
For class A, there are 80 true positives, five false positives and ten false negatives. Its F1 is 2 times 80 divided by (160 + 5 + 10) = 160/175, approximately 0.9143.
For class B, there are five true positives, ten false positives and five false negatives. Its F1 is 10/(10 + 10 + 5) = 0.4. Macro F1 is (0.9142857 + 0.4)/2, approximately 0.6571.
Accuracy is 85/100 = 0.85, which looks stronger because most examples belong to the better-served class A. The macro result highlights the weak class B performance. It does not establish the cost of either error type or the uncertainty of estimates from this small invented test.
Illustrative case study
Fictional case: Linden Routing sees a high overall score for its ticket classifier. A closer review shows that rare specialist requests are often sent to the wrong team, even though routine requests are handled well.
Analysts add macro F1 and per-class recall to the evaluation, keeping the label set fixed across model versions. They also report the number of examples in each category and manually review errors in the rare classes. The revised report gives decision-makers a clearer view of the trade-off without replacing operational cost analysis with a single new metric.
Common misconceptions and mistakes
Macroaveraging is not the same as pooling all true positives, false positives and false negatives before calculating a metric; that is microaveraging. It also differs from a support-weighted average, which gives larger classes more influence.
A high macro score does not guarantee acceptable performance for every class. Opposing changes can cancel in the mean, and a rare class can have a very uncertain estimate. Do not assume macro F1 equals the F1 computed from averaged precision and recall. State how undefined per-class values are treated rather than silently dropping difficult categories.
Business use
Use macroaveraging when equal attention across categories is relevant to the evaluation question. Report it with per-class metrics, support counts and, where useful, a complementary micro or weighted score. Select the averaging scheme before comparing models to reduce the temptation to choose whichever summary looks best.
Connect evaluation to the cost and consequences of errors. Equal class weighting is a transparent convention, not a universal business objective or a fairness guarantee. For small categories, gather sufficient test evidence and examine stability before relying on a small change in the macro score.
People also ask
Does macroaveraging give rare classes more weight than common classes?
It gives each class equal weight in the mean, so rare classes have more influence than they would in a sample-dominated summary.
Is macro F1 an average of class F1 scores?
Under the usual convention used here, yes.
Can the class list affect the answer?
Yes. Including absent classes or excluding a category changes the averaging definition and may change the result.
Check your understanding
Three included classes have F1 values 0.9, 0.6 and 0.3. What is their macro F1?
Answer: (0.9 + 0.6 + 0.3)/3 = 0.6. The calculation gives each class equal weight and does not use its number of test examples.
Related terms
- Microaveraging
- Precision
- Recall
- weighted averaging
- F1 score
- class imbalance
- support and confusion matrix
Learn next
calculate per-class F1, macro F1 and micro F1 from one small confusion matrix. Change the performance of a rare class and observe how each summary responds. Keep the included labels and zero-division convention fixed throughout.
More in Retrieval and knowledge systems
- Location-based recommendation - Location-based recommendation is the selection or ranking of suggested items using geographical context as part of the decision.
- Long tail - The long tail is the large collection of relatively infrequent items or events beyond a small group of highly popular ones in a ranked distribution.
- Low-dimensional embedding - A low-dimensional embedding represents an item using relatively few numerical coordinates while aiming to retain relationships useful for a task.
- Match rating approach - The Match rating approach (MRA) is a rule-based method for comparing names through compact phonetic encodings and a rating procedure.
- Metaphone - Metaphone is a phonetic encoding algorithm that converts a word into a compact code using spelling rules intended to approximate aspects of its pronunciation.
- Moving average - A moving average is an average recalculated over a window that moves through a sequence of observations.
Sources
Primary sources: scikit-learn, precision_recall_fscore_support API, averaging modes and undefined-value handling: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html
scikit-learn, Model evaluation guide, multiclass and multilabel averaging conventions: https://scikit-learn.org/stable/modules/model_evaluation.html
Previous: Machine translation Next: Macroblock