Macro, weighted and micro F1 from one confusion matrix
Calculate macro, weighted and micro F1 on the same 100 tickets. See how a model can score 0.90 on micro F1 while missing an entire support queue.
- Author
- Salon Rai
- 3 min read
A support router sends 90 of 100 tickets to the right team and misses every cancellation request. Its micro F1 is 0.90, its weighted F1 is about 0.876, and its macro F1 is about 0.582. All three describe the same predictions. To understand the difference, keep the confusion matrix fixed and change what gets a vote in the average.
Start with the three queues
Rows in this matrix are the teams that should have received a ticket. Columns are the model’s predictions. Every ticket has exactly one true team and one predicted team. The last column contains no predictions, even though the cancellation queue has five actual tickets.
| Actual team | Predicted billing | Predicted technical | Predicted cancellation | Support |
|---|---|---|---|---|
| Billing | 78 | 2 | 0 | 80 |
| Technical | 3 | 12 | 0 | 15 |
| Cancellation | 4 | 1 | 0 | 5 |
For each team, treat its own tickets as positive and every other team as negative. Its F1 is twice the true positives divided by twice the true positives plus false positives plus false negatives. A convenient equivalent is twice the diagonal count divided by the sum of the corresponding row and column totals. scikit-learn F1 score definition and averaging modes
Billing has 80 actual tickets and 85 predicted tickets. Its F1 is 156 divided by 165, about 0.945. Technical has 15 actual and 15 predicted, so its score is 24 divided by 30, or 0.8. Cancellation has five actual tickets and zero correct predictions. Its score is zero. That last value is well defined because there are actual cases to miss.
Average the scores three ways
Macro F1 gives each included class equal weight. Add the three class scores and divide by three. The cancellation queue accounts for one third of this average even though it handles only one twentieth of the traffic. Macro F1 answers a useful release question when all three teams must be served competently.
Weighted F1 multiplies each class score by its actual support before taking the mean. Here billing supplies 80% of the weight. Weighted F1 averages the class-level F1 values. Taking weighted precision and weighted recall and then calculating their harmonic mean is a different calculation.
Micro F1 pools the class counts before calculating one F1. There are 90 true positives across the three classes. Every misroute creates one false positive for the predicted team and one false negative for the actual team. With one true and one predicted label per item and all classes included, micro F1 equals accuracy. These conditions matter for multilabel tasks or reports restricted to selected classes.
Reproduce the numbers without a model
This Python snippet depends only on the standard library. The explicit totals make it possible to verify a spreadsheet or dashboard even when the original classifier is unavailable.
matrix = [[78, 2, 0], [3, 12, 0], [4, 1, 0]]
actual = [sum(row) for row in matrix]
predicted = [sum(col) for col in zip(*matrix)]
correct = [row[i] for i, row in enumerate(matrix)]
scores = [
2 * hits / (a + p)
for hits, a, p in zip(correct, actual, predicted)
]
macro = sum(scores) / len(scores)
weighted = sum(f * n for f, n in zip(scores, actual)) / sum(actual)
micro = 2 * sum(correct) / (sum(actual) + sum(predicted))
print([round(x, 3) for x in scores]) # [0.945, 0.8, 0.0]
print(round(macro, 3), round(weighted, 3), round(micro, 3))
The fixture includes each class in the actual data. If a future period contains neither actual nor predicted cancellations, its denominator is zero. Choose and disclose an undefined-score policy before comparing periods. Some dashboards exclude absent classes while others substitute zero. That decision can move the macro average even when both systems saw identical predictions.
Decide what should block a release
Imagine an updated router catches four cancellation tickets but starts sending a large number of billing tickets to cancellation too. The cancellation team’s recall improves, but its queue fills with extra work. Inspect both the actual support and predicted volume. A single F1 value cannot tell an operator how many tickets to staff for, and a higher macro average can conceal a drop in another team’s performance.
On a dashboard, put the aggregate next to a small per-team table with support, precision, recall and predicted volume. When comparing two models, evaluate them on the same tickets and label set. Tracking weighted F1 across weeks also requires watching the traffic mix: onboarding a customer who generates many easy billing questions can lift the average without a routing change.
Next steps
Pick the aggregate that matches the decision and write its averaging rule beside the number. Keep a separate minimum or review condition for a queue whose failure would be expensive. For an example of how one missed case changes recall and review workload, see why a classifier can have high accuracy and zero recall.

Written by