A three-class classifier produces confusion matrix rows (true classes A, B, C; predicted columns A, B, C) of [45,5,0], [6,21,3] and [4,4,12]. 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 F1 equally across all classes regardless of support, whereas micro-F1 pools all true positives (TP), false positives (FP) and false negatives (FN) globally; in single-label multi-class classification, every error is simultaneously one FP and one FN, forcing micro-averaged precision micro-P, micro-averaged recall micro-R, micro-F1 and accuracy to be equal.

Steps

  1. Extract per-class counts from the matrix (total N=100): Class A has TPA=45,FNA=5,FPA=10; Class B has TPB=21,FNB=9,FPB=9; Class C has TPC=12,FNC=8,FPC=3.
  2. Compute per-class F1 (a single score that combines precision and recall) =2TP2TP+FP+FN: F1,A=90105=67≈0.857; F1,B=4260=0.700; F1,C=2435≈0.686.
  3. Compute macro-F1: 13(67+710+2435)=157210≈0.748.
  4. Compute micro-F1: total TP=45+21+12=78, total FP=10+9+3=22, total FN=5+9+8=22. Thus micro-F1=2(78)2(78)+22+22=78100=0.780, which equals overall accuracy (78/100).
  5. 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 ∑FPc=∑FNc=N−∑TPc. Prefer macro-F1 when minority classes (like C) matter as much as the majority class.

Common mistakes

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 α=0.05 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?