Confusion Matrix
noun
say it: “kun-FYOO-zhun MAY-triks” /kənˈfjuʒən ˈmeɪtrɪks/
A table that counts a classifier's correct and incorrect predictions, sorted by the real answer and the predicted one.
What is a confusion matrix?
A confusion matrix is a table that counts a classifier's guesses by what the answer really was and what the model
said, so you see which mistakes it makes. For a yes-or-no model, scikit-learn's confusion_matrix() puts the true
negatives and false positives on the first row, the false negatives and true positives on the second.
from sklearn.metrics import confusion_matrix
actual = [1, 0, 0, 1, 1, 0] # 1 = fraud
guessed = [1, 0, 1, 0, 1, 0]
print(confusion_matrix(actual, guessed))
# [[2 1]
# [1 2]]
In a sentence
- “Accuracy hid the problem; the confusion matrix showed it.”
- “The confusion matrix showed 12 frauds the check had missed.”
Level: Journeyman · More AI Basics terms at this level
Updated