Metrics & Evaluation

Macro vs Micro vs Weighted Averaging

Aggregating precision, recall, and F1 scores across multiple classes in multi-class classification tasks.

🟡 intermediate5 min readmetrics
Macro, Micro, and Weighted Averaging aggregate evaluation metrics across multi-class classification models. Macro Averaging calculates metrics independently for each class and takes an unweighted arithmetic mean, treating all classes equally. Micro Averaging pools total true positives, false positives, and false negatives globally across all classes, reflecting overall instance accuracy. Weighted Averaging weights per-class metrics by class support volume, accounting for class imbalance.

Aggregating Metrics Across Multiple Classes

In binary classification, calculating Precision and Recall is straightforward.

In Multi-Class Classification (for example classifying customer tickets into 10 distinct topics), we calculate Precision and Recall for each class independently.

To summarize performance into a single overall metric, we choose from Three Averaging Methods:

┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. MACRO AVERAGE         │ 2. MICRO AVERAGE         │ 3. WEIGHTED AVERAGE      │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ Unweighted mean of       │ Pools total TP, FP, FN   │ Weights per-class        │
│ per-class metrics. Treats│ globally across all      │ metrics by sample        │
│ all classes EQUALLY!     │ instances.               │ volume (support).        │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘

Worked Example with Imbalanced Classes

Suppose we classify images into three categories: Cat (1000 samples), Dog (1000 samples), and Capybara (10 samples).

Class Performance:
- Cat:      Precision = 0.90 (High)
- Dog:      Precision = 0.90 (High)
- Capybara: Precision = 0.00 (Total Failure!)

1. Macro Averaging (Equal Class Weight)

Calculates the unweighted mean across class scores:

$$\text{Macro Precision} = \frac{0.90 + 0.90 + 0.00}{3} = 0.60$$

Macro averaging highlights the failure on Capybara because every class counts for one third of the score.

2. Weighted Averaging (Sample Volume Weight)

Weights each class score by its sample count (support):

$$\text{Weighted Precision} = \frac{1000(0.90) + 1000(0.90) + 10(0.00)}{2010} = 0.895$$

Weighted averaging hides the failure on Capybara because common classes dominate the score.

3. Micro Averaging (Global Instance Pooling)

Pools true positives, false positives, and false negatives globally across all 2010 instances before calculating precision. In single label classification, Micro F1 equals overall Accuracy.

Decision Guide

GoalRecommended Averaging Method
Detect failures on rare minority classesMacro Average
Measure overall system instance accuracyMicro Average
Balance sample counts while accounting for imbalanceWeighted Average

Say this out loud

Macro, Micro, and Weighted averaging aggregate evaluation metrics across multi class problems. Macro averaging calculates metrics for each class independently and averages them equally, making it ideal for detecting failures on rare classes. Micro averaging pools global true positives and false positives across all instances. Weighted averaging scales per class scores by sample volume.

Followups to expect

  1. Why are Micro Precision and Micro Recall equal in single-label multi-class classification? Because every misclassification counts simultaneously as a False Positive for the wrong predicted class and a False Negative for the true ground truth class.
  2. What is Class Support in a classification report? The total number of actual ground truth instances belonging to a specific class in the evaluation dataset.

Check yourself

Question 1 of 3

Which averaging method treats all classes equally regardless of how many samples belong to each class?

More in Metrics & Evaluation

See all →
Precision, Recall & F14 minWhy Accuracy Lies4 minROC-AUC vs PR-AUC4 min