Confusion Matrix
Last Updated: July 29, 2026 | By Mihail Sebastian | AI Dictionary
A table sorting a classifier's predictions into true and false positives and negatives – the four counts that precision, recall, and F1 derive from.
What is a Confusion Matrix?
A confusion matrix is a table that compares a classification model’s predictions against the true labels, sorting every prediction into one of four cells: true positive, false positive, true negative, or false negative.
It is the backbone of classification metrics. Precision, recall, the F1 score, accuracy, and the ROC curve are all computed from its four counts, so any serious look at a classifier’s errors starts here.
How a Confusion Matrix Works
Rows hold the actual classes and columns the predicted ones (some libraries flip this; check before reading one).
| Predicted positive | Predicted negative | |
|---|---|---|
| Actually positive | True positive (TP) | False negative (FN) |
| Actually negative | False positive (FP) | True negative (TN) |
A perfect model puts everything on the diagonal. The two off-diagonal cells are the two distinct ways to be wrong, and they rarely cost the same: a false negative is a miss, a false positive is a false alarm. From the four counts: precision = TP / (TP + FP), recall = TP / (TP + FN), accuracy = (TP + TN) / total.
With more than two classes the matrix grows to N x N, and the off-diagonal cells show exactly which classes the model confuses with which – the pattern the name refers to.
Example of a Confusion Matrix
A spam filter processes 1,000 emails, 200 of them spam:
| Predicted spam | Predicted not spam | |
|---|---|---|
| Actual spam | 170 | 30 |
| Actual not spam | 20 | 780 |
Accuracy is 95%, which sounds excellent. The matrix shows what that number hides: 30 spam messages reached inboxes (recall 0.85) and 20 legitimate emails were buried in the spam folder (precision about 0.89).
Whether that trade is acceptable is a judgment about costs, not statistics. The matrix is what makes the judgment possible.
Related AI terms: Precision · Recall · F1 Score · Model Evaluation · Ground Truth
Did you like the Confusion Matrix gist?
Learn about 250+ need-to-know artificial intelligence terms in the AI Dictionary.
Mihail Sebastian — Writes about AI governance, regulation, and the technology behind them. Placeholder bio — replace with a real credential line. About