Confusion Matrix Calculator
Turn four counts into every standard classification metric, including the ones that stay honest when the classes are imbalanced.
Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.
What the Confusion Matrix Calculator does
This confusion matrix calculator will turn four counts into every standard classification metric, including the ones that stay honest when the classes are imbalanced. Fill in all 4 fields and the result updates as you type — there is no Calculate button to press and no page reload. It is most often used for evaluating a classifier from the four counts your validation run produced. You may also want the exponent rules calculator.
How to use it
- Enter the four counts from your confusion matrix.
- Read F1 for a single balanced figure, or precision and recall separately.
- Check MCC and balanced accuracy when one class is much larger than the other.
How it works
Four counts describe a binary classifier completely, and every metric here is a different way of dividing them. Precision asks: of the things it flagged, how many were right? Recall asks: of the things it should have flagged, how many did it catch? They pull in opposite directions — a classifier that flags everything has perfect recall and terrible precision — which is why F1, their harmonic mean, exists as a single number that cannot be gamed by maximising one alone.
Accuracy is the metric to distrust. On a dataset that is 97% negative, a classifier that predicts "negative" every time scores 97% accuracy while being completely useless, and the reading line above says so when it detects that shape. Balanced accuracy averages recall and specificity, which fixes the obvious part of the problem. The Matthews correlation coefficient goes further: it uses all four cells and stays near zero for any classifier that is not genuinely better than chance, which makes it the most reliable single number on an imbalanced problem. It runs from −1 to +1 rather than 0 to 1.
Which metric matters is a question about consequences, not about statistics. Screening for a serious disease wants recall, because a missed case is far worse than a false alarm that gets a second test. Flagging accounts for suspension wants precision, because wrongly suspending real customers is the expensive error. Reporting F1 alone hides that choice; reporting precision and recall separately makes it visible, which is why both are shown here.
When to use it
- Evaluating a classifier from the four counts your validation run produced.
- Comparing two models on the metric that matches the cost of each error.
- Showing why a 97%-accurate model on imbalanced data may be worthless.
- Getting MCC, which most calculators leave out, for a skewed dataset.
Common mistakes to avoid
- Reporting accuracy on imbalanced data. The majority-class baseline is usually most of the score.
- Optimising F1 when the two error types have very different costs.
- Swapping false positives and false negatives. FP is predicted positive but actually negative.
- Comparing F1 across datasets with different class balance, where the same score means different things.
Frequently asked questions
What is the difference between precision and recall?
Precision is how many of the flagged items were right; recall is how many of the real positives were caught. A model can be excellent at one and poor at the other.
Why is accuracy a bad metric here?
Because on imbalanced data the majority class dominates it. At 97% negatives, predicting "negative" every time scores 97% while detecting nothing.
What is MCC and why use it?
The Matthews correlation coefficient uses all four cells and runs from −1 to +1. It stays near zero for a classifier no better than chance, which makes it hard to flatter on skewed data.
Which metric should I report?
Whichever matches the cost of being wrong — recall when missing a positive is expensive, precision when a false alarm is. Report both; F1 alone hides the trade-off you chose.