Loading…
Glossary term
A table showing how many predictions a classifier got right and wrong for each class.
A confusion matrix is a table of what a classifier predicted against what was true. Its four cells are true positives, false positives, false negatives and true negatives.
From it you can compute accuracy, precision, recall and more, and see which classes are being confused.
| Predicted positive | Predicted negative | |
|---|---|---|
| Actually positive | TP: 40 | FN: 10 |
| Actually negative | FP: 5 | TN: 45 |
Build a confusion matrix
from sklearn.metrics import confusion_matrix
print(confusion_matrix(y_true, y_pred))It shows where a model goes wrong, not just how often.