🟪 1-Minute Summary

A confusion matrix shows the performance of a classification model by comparing actual vs predicted labels. Four quadrants: True Positive (TP), False Positive (FP), True Negative (TN), False Negative (FN). All classification metrics (precision, recall, accuracy, F1) derive from these four values. Essential for understanding where your model makes mistakes.


🟦 Core Notes (Must-Know)

Structure of Confusion Matrix

[Content to be filled in]

                Predicted
              Pos     Neg
Actual  Pos   TP      FN
        Neg   FP      TN

The Four Quadrants

[Content to be filled in]

  • TP (True Positive): Correctly predicted positive
  • FP (False Positive): Incorrectly predicted positive (Type I error)
  • TN (True Negative): Correctly predicted negative
  • FN (False Negative): Incorrectly predicted negative (Type II error)

How to Read It

[Content to be filled in]


🟨 Interview Triggers (What Interviewers Actually Test)

Common Interview Questions

  1. “Explain the confusion matrix”

    • [Answer: Show the 2x2 grid, explain each quadrant]
  2. “What’s worse: FP or FN?”

    • [Answer: Depends on context - e.g., disease: FN worse, spam: FP worse]
  3. “How do you derive precision from the confusion matrix?”

    • [Answer: TP / (TP + FP)]

🟥 Common Mistakes (Traps to Avoid)

Mistake 1: Confusing rows and columns

[Content to be filled in]

Mistake 2: Not considering class imbalance

[Content to be filled in]


🟩 Mini Example (Quick Application)

Scenario

[Binary classifier evaluation]

Solution

from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
import matplotlib.pyplot as plt

# Example to be filled in


Navigation: