Paste a confusion matrix with any number of classes to get precision, recall and F1 for each class, their macro and weighted averages, overall accuracy and Cohen's kappa.
Rows = actual class · columns = predicted class
One row per actual class. An optional first line of names labels the classes.
A confusion matrix is a table that counts how often each actual class was predicted as each possible class. Correct predictions sit on the diagonal; everything off the diagonal is a mistake, and its position shows exactly which classes get confused.
For each class you can read off precision (of the items predicted as this class, how many were right?) and recall (of the items truly in this class, how many were found?). F1 combines them.
Summarising many classes takes care. A macro average treats every class equally, a weighted average reflects class sizes, and Cohen's kappa discounts the agreement you'd get by chance.
As given in Sokolova & Lapalme (2009) and Cohen (1960). See Sources.
pₒ is the observed accuracy; pₑ is the accuracy expected if predictions were random with the same class frequencies.
The matrix shows where the trouble is: 6 dogs were called rabbits. The weighted average hides this because rabbits are a small class; the macro average exposes it.
The pet classifier above, three ways.
| Average | Precision | Recall | F1 | Use when |
|---|---|---|---|---|
| Macro | 79.2% | 80.3% | 79.6% | Every class matters equally |
| Weighted | 81.9% | 81.7% | 81.6% | Bigger classes matter more |
| Micro | 81.7% | 81.7% | 81.7% | Every item matters equally |
Here, rows are actual classes and columns are predicted ones, the convention used by scikit-learn. Check your source before pasting.
The number of items actually in each class: the row total.
In single-label classification, every mistake is one false positive for one class and one false negative for another, so the totals match.
A common rough guide: above 0.8 is excellent, 0.6–0.8 substantial, 0.4–0.6 moderate.
Its precision is undefined and shown as a dash. The averages leave it out rather than counting it as 0.
Yes, but the classification accuracy calculator gives more binary-specific measures, such as MCC and specificity.
No. Without a label line, classes are numbered in row order.
Those need one binary matrix per label. This page assumes each item has exactly one true class.
Related Tools
Evaluate classification models.
Diagnostic test accuracy.
Diagnostic test performance.
Updated diagnostic probability.
Risk ratio comparison.
Event probability.