What Is a Confusion Matrix? A Plain-Language Explanation
A confusion matrix is a table used to evaluate a classification model by comparing predicted labels with actual labels, organizing the results into four counts: true positives, true negatives, false positives, and false negatives.
The simple analogy
A teacher marking yes/no answers wants to know not just how many were wrong, but the direction of each mistake. A confusion matrix separates correct answers from the two kinds of errors so the model's weaknesses are visible.
The four cells
| Term | Meaning |
|---|---|
| True Positive (TP) | Correctly predicted positive |
| True Negative (TN) | Correctly predicted negative |
| False Positive (FP) | Actually negative, predicted positive |
| False Negative (FN) | Actually positive, predicted negative |
Metrics derived from it
- Accuracy: the share of all predictions that were correct.
- Precision: of predicted positives, how many were real.
- Recall: of actual positives, how many were caught.
Why accuracy alone can mislead
When one class is much more common, a model can show high accuracy while missing the rare class. The confusion matrix reveals those errors directly.
Honest caveats
A confusion matrix is mainly used for classification rather than regression, and it becomes larger with more classes. It describes performance but does not by itself explain why errors occur.
FAQ
What is a false positive?
A negative case that the model incorrectly predicted as positive.
What is a false negative?
A positive case that the model incorrectly predicted as negative.
How do precision and recall differ?
Precision focuses on the reliability of positive predictions, while recall focuses on how many real positives were found.
When is accuracy misleading?
When classes are imbalanced, a dominant class can inflate accuracy.
Key takeaways
- A confusion matrix compares predicted and actual labels.
- It uses four counts, including two error types.
- Precision and recall derive from it.
- It helps expose class imbalance problems.
Continue with what is cross-validation and what is model evaluation.
Sources
Learn by doing
Read a guide, then practice with bite-sized AI lessons you can take offline.
Start learning free