It shows not just how often a model is wrong, but how.
Direct answer
A confusion matrix is a table of actual versus predicted classes. For two classes it has four cells: true positives (TP), false positives (FP), true negatives (TN) and false negatives (FN). From it you calculate accuracy, precision and recall.
Layout
| Predicted positive | Predicted negative | |
|---|---|---|
| Actually positive | TP | FN |
| Actually negative | FP | TN |
Example
A disease test on 100 people:
- TP = 8, FN = 2, FP = 5, TN = 85.
- Precision = 8 ÷ 13 ≈ 62 percent.
- Recall = 8 ÷ 10 = 80 percent.
In scikit-learn
from sklearn.metrics import confusion_matrix
print(confusion_matrix(y_true, y_pred))
Where Teyro fits
Teyro's Machine Learning for Beginners course turns this into short lessons you can play in a few minutes a day. It has 200 lessons, and you can start free.
The bottom line
Look at the types of errors, not just the total.



