Macro, Micro & Weighted F1 Score Calculator (Multiclass)
Paste a multiclass confusion matrix and get per-class precision, recall and F1 plus the three averages everyone mixes up, macro, micro and weighted, with accuracy and every step of the arithmetic shown. Matches scikit-learn.
How it works
A multiclass model is scored from its confusion matrix, a K×K grid where C[i][j] is the number of samples whose true class is i and whose predicted class is j. The diagonal holds correct predictions. From that single grid every metric below is derived, using the definitions in scikit-learn's precision_recall_fscore_support.
For each class c the tool reads four counts straight off the matrix:
- TP = C[c][c] (correct for c)
- FP = column c total − TP (predicted c, truly other)
- FN = row c total − TP (truly c, predicted other)
- support = row c total = TP + FN (true instances of c)
Precision is TP / (TP + FP), recall is TP / (TP + FN), and the per-class F1 is their harmonic mean, 2·P·R / (P + R). When a denominator is zero, a class never predicted, or with no true samples, the metric is defined as 0, matching classification_report, so you never see a NaN.
The three averaging modes differ only in how they combine those per-class numbers, and that is exactly what trips people up:
- Macro, the plain mean of the per-class F1 over the K classes:
Macro-F1 = (ΣF1_c) / K. Every class counts once, so a poorly-handled minority class hurts as much as the majority class. - Weighted, the mean weighted by each class's support:
Weighted-F1 = (Σ support_c · F1_c) / N. Larger classes pull the average toward their own score. - Micro, pool first, then divide:
Micro-F1 = 2·ΣTP / (2·ΣTP + ΣFP + ΣFN). Because a single-label error is one FP and one FN at the same time, ΣFP = ΣFN, so micro-precision, micro-recall and micro-F1 all collapse toΣTP / N, plain accuracy. That is why scikit-learn prints an “accuracy” row rather than a micro row.
The calculator surfaces the pooled ΣTP, ΣFP and ΣFN it uses for micro and the support weights it uses for weighted, so the arithmetic is auditable, and it flags when macro-F1 falls well below micro-F1, the tell-tale sign that class imbalance is hiding a weak minority class.
Worked examples
Frequently asked questions
Sources & references
- scikit-learn: precision_recall_fscore_support (macro / micro / weighted definitions)
- scikit-learn User Guide: Precision, recall and F-measures
- Wikipedia: F-score (precision/recall harmonic mean)
The definitions and both worked examples were last cross-checked against scikit-learn's classification_report on 2026-07-12.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us, our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] , most fixes ship within 24 hours.