Class-Specific vs Macro vs Micro Averaging
What you'll learn: How to aggregate per-class metrics into single scores for multiclass classification problems.
The Core Problem
When evaluating a multiclass classifier (say, predicting three diseases), you can compute precision, recall, or F1 score for each class separately. But often you need one number to summarize overall performance. How do you combine three precision values into one? That's where averaging strategies come in.
Three Aggregation Strategies
Class-Specific Metrics
These are the individual metrics per class before any averaging. For a 3-class problem, you'd have three precision values, three recall values, etc. Use these when you need to understand performance on specific classes—maybe Class 2 (rare disease) is what really matters clinically.
Macro Averaging
Calculate the metric for each class, then take the simple average. All classes get equal weight regardless of size.
Analogy: Three students scored 90%, 80%, and 70%. Macro average = (90+80+70)/3 = 80%.
When to use: When all classes matter equally, even if some are rare. Treats a 50-sample minority class the same as a 5000-sample majority class.
Micro Averaging
Pool all predictions together (combine all true positives, false positives, false negatives across classes), then compute one metric from the pooled confusion matrix.
Analogy: Count all correct answers from all students together, then divide by all questions attempted by everyone.
When to use: When larger classes should have more influence, or when class imbalance exists and you care about overall accuracy-like behavior.
Key Difference
Macro averaging treats classes equally; micro averaging weights classes by their frequency in the data.
Key Takeaway: Macro averaging gives equal importance to each class; micro averaging weights by sample size. Choose based on whether rare classes should influence your metric as much as common ones.