Math · Machine learning · Multiclass metrics
Multiclass F1 calculator.
Paste a confusion matrix with any number of classes and get per-class precision, recall and F1, then macro, micro and weighted averages, multiclass MCC and Cohen's kappa.
For the 3-class matrix in the scikit-learn f1_score documentation example, macro F1 is 0.267 and micro F1 is 0.333: two of the three classes score F1 = 0 and drag the macro average down, while micro F1 is just accuracy (2 correct out of 6).
Inputs
Your result
Fill the form and press Calculate.
How the averages differ
For each class treat it as "positive" and the rest as "negative" to get TP, FP and FN, then precision = TP/(TP+FP), recall = TP/(TP+FN) and F1 = 2TP/(2TP+FP+FN). scikit-learn defines the averages like this: macro is the unweighted mean of the per-class scores, so it does not take label imbalance into account; micro counts total true positives, false negatives and false positives globally; weighted averages per-class scores weighted by each class's presence in the true data. scikit-learn also notes that macro F1 is the arithmetic mean of per-class F1 scores, not the harmonic mean of the averaged precision and recall.
Worked example
Matrix rows [2,0,0], [1,0,1], [0,2,0] (the scikit-learn documentation example with y_true = [0,1,2,0,1,2], y_pred = [0,2,1,0,0,1]). Class 1: TP 2, FP 1, FN 0, F1 = 4/5 = 0.8. Classes 2 and 3 have TP 0, so F1 = 0. Macro F1 = (0.8 + 0 + 0)/3 = 0.2667 and micro F1 = 2/6 = 0.3333, matching the 0.267 and 0.33 that scikit-learn prints.
Choosing an average
Use macro when every class matters equally, including rare ones; use micro when overall sample-level performance matters; use weighted to reflect class frequency while still reporting per-class scores. In single-label multiclass data, micro precision, recall and F1 all equal accuracy, which is why this page shows them equal. Multiclass MCC uses the generalisation that scikit-learn supports (Gorodkin 2004): (c·s − Σpktk) / √((s2 − Σpk2)(s2 − Σtk2)), with c correct predictions, s samples, and pk, tk the predicted and true counts of class k.
Sources, opened 15 October 2026: scikit-learn User Guide, Metrics and scoring; scikit-learn f1_score; scikit-learn matthews_corrcoef.
Frequently asked questions
What is the difference between macro and micro F1?
Macro F1 averages the per-class F1 scores equally. Micro F1 pools all TP, FP and FN first, then computes one F1. In single-label problems micro F1 equals accuracy.
When should I use weighted F1?
When classes are imbalanced and you want overall performance that reflects how often each class occurs, while still being built from per-class scores. It weights each class by its support.
Why is macro F1 lower than accuracy?
Macro treats rare, poorly predicted classes the same as common ones. One class with F1 of 0 pulls the macro average down even if accuracy is high.
Should rows be actual or predicted?
Rows are actual classes and columns predicted classes, as in scikit-learn. If your matrix is transposed, precision and recall swap places; F1 is unchanged.
What happens when a class is never predicted?
Its precision is undefined; scikit-learn reports 0 by default and warns, and this calculator does the same so macro averages match.
Learning and planning aid
Results are computed in your browser from the numbers you enter and the formulas described above. Check them against your own evaluation code before relying on them in a paper or a production decision.