3.2 Confusion Matrix
[video] /api/lesson-media/videos/9b417aa2-5e9f-4ae3-a9db-2a3b7f03f372-1794891209190-3cda32dadfda5d69.mp4
[markdown] content available only on the platform
[markdown] content available only on the platform
Flashcards · 3.2 Confusion Matrix
Confusion matrix — A table counting predictions by actual class (rows) and predicted class (columns).
[[3, 2], [1, 1]] for the seven dog/cat photos.
Positive class — The class we care about detecting, chosen according to the real-world problem.
'has disease' in medical screening; 'dog' in the lesson.
True positive (TP) — The model predicts positive and the sample really is positive.
Predicted dog, actually dog (photos 1, 4, 7).
False positive (FP) — The model predicts positive but the sample is negative: a false alarm.
Predicted dog, actually cat (photo 3).
False negative (FN) — The model predicts negative but the sample is positive: a miss.
Predicted cat, actually dog (photos 2 and 6).
True negative (TN) — The model predicts negative and the sample really is negative.
Predicted cat, actually cat (photo 5).
Type I error — Another name for a false positive: flagging something as positive when it is not.
A legitimate email flagged as spam.
Type II error — Another name for a false negative: missing a real positive case.
A sick patient told they are healthy.
confusion_matrix() — scikit-learn function returning the matrix; labels are sorted unless you pass labels=.
confusion_matrix(y_true, y_pred, labels=['dog', 'cat'])
