1. F1 Score Recap (Binary Case)

  • F1 score is the harmonic mean of precision and recall:

$F1 = \frac{2 \times Precision \times Recall}{Precision + Recall}$

  • Balances the trade-off between precision (how many predicted positives are correct) and recall (how many actual positives were found).
  • Useful when classes are imbalanced or when both false positives and false negatives matter.

2. F1 in Multiclass Problems

For K classes, compute an F1 score per class (using one-vs-rest logic):

  • F1(A) = harmonic mean of Precision(A) & Recall(A)
  • F1(B) = harmonic mean of Precision(B) & Recall(B)
  • F1(C) = harmonic mean of Precision(C) & Recall(C)

3. Macro F1 Definition

  • Take the average of F1 scores across all classes.

$F1_{macro} = \frac{1}{K} \sum_{i=1}^{K} F1_i$

  • Each class contributes equally, regardless of size.

4. Macro vs Micro vs Weighted F1

  • Macro F1: Equal weight for each class → highlights poor performance on minority classes.
  • Micro F1: Compute global TP, FP, FN, then derive precision/recall/F1. Dominated by majority classes.
  • Weighted F1: Average F1 per class, but weighted by class frequency.

5. Example

Suppose 3 classes:

  • Precision(A) = 0.80, Recall(A) = 0.80 → F1(A) = 0.80
  • Precision(B) = 0.60, Recall(B) = 0.40 → F1(B) = 0.48
  • Precision(C) = 0.50, Recall(C) = 0.25 → F1(C) = 0.33

$F1_{macro} = \frac{0.80 + 0.48 + 0.33}{3} = 0.54$

So, Macro F1 = 0.54, even though Class A performs well, Classes B & C drag the average down.


Summary

  • Macro F1 = average of class-wise F1 scores.
  • Gives equal importance to all classes.
  • Best used when you care about performance on all classes equally, including small/minority ones.
  • Often reported along with Micro F1 for a balanced view.