A three-class classifier produces confusion matrix rows (true classes A, B, C; predicted columns A, B, C) of , and . What are macro-F1 and micro-F1, why does micro-F1 equal overall accuracy here, and when is macro-F1 preferred?
ML systems and evaluation, Classification metrics
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can compute multi-class F1 averages and understand how class imbalance separates micro- and macro-averaging.
Key idea
Macro-F1 averages equally across all classes regardless of support, whereas micro-F1 pools all true positives (), false positives () and false negatives () globally; in single-label multi-class classification, every error is simultaneously one and one , forcing micro-averaged precision , micro-averaged recall , and accuracy to be equal.
Steps
- Extract per-class counts from the matrix (total ): Class A has ; Class B has ; Class C has .
- Compute per-class (a single score that combines precision and recall) : ; ; .
- Compute macro-F1: .
- Compute micro-F1: total , total , total . Thus , which equals overall accuracy ().
- Explain why micro-F1 equals accuracy: each misclassified example creates one false negative for its true class and one false positive for its predicted class, so . Prefer macro-F1 when minority classes (like C) matter as much as the majority class.
Common mistakes
- Averaging per-class precision and recall first and then taking their harmonic mean; macro-F1 averages the per-class scores directly.
- Claiming micro-F1 equals accuracy in multi-label classification; that identity only holds when each item has exactly one true label and one predicted label.
How long your answer should be
Five lines of arithmetic plus two sentences explaining the identity and choice; 4 minutes.
Read this
Previous in ML systems and evaluation: What is the difference between unstructured magnitude pruning and structured pruning, and why does 80% unstructured sparsity often give little wall-clock speedup on standard GPUs?
Next in ML systems and evaluation: An A/B test evaluates 20 independent metrics at significance level when the treatment actually has zero effect on all of them. What is the probability of getting at least one false positive, how does Bonferroni correction adjust the threshold, and why does sequential peeking cause a similar problem?