Home Knowledge Base Confusion Matrix

Confusion Matrix is the fundamental evaluation tool for classification models that breaks accuracy into four categories — True Positives, True Negatives, False Positives, and False Negatives — revealing not just how often the model is right, but HOW it fails (does it miss actual positives or cry wolf too often?), enabling practitioners to optimize for the specific type of error that matters in their domain: cancer screening demands high recall (catch every case), spam filtering demands high precision (don't delete real email).

The Four Quadrants

Predicted PositivePredicted Negative
Actually PositiveTrue Positive (TP) ✓False Negative (FN) — MISS
Actually NegativeFalse Positive (FP) — FALSE ALARMTrue Negative (TN) ✓

Derived Metrics

MetricFormulaQuestion It AnswersOptimize When
Accuracy(TP + TN) / Total"How often is the model correct overall?"Classes are balanced
PrecisionTP / (TP + FP)"Of all positive predictions, how many were right?"False alarms are costly (spam filter)
Recall (Sensitivity)TP / (TP + FN)"Of all actual positives, how many did we catch?"Missing positives is dangerous (cancer)
F1 Score2 × (Precision × Recall) / (Precision + Recall)"What is the harmonic mean of precision and recall?"You need both precision and recall
SpecificityTN / (TN + FP)"Of all actual negatives, how many did we correctly identify?"False positives are costly (drug testing)

Real-World Trade-offs

DomainPriorityWhyTolerance
Cancer ScreeningHigh Recall (>95%)Missing a cancer case can be fatalAccept some false alarms (further testing is cheap)
Spam FilterHigh Precision (>99%)Deleting a real email is worse than letting spam throughAccept some spam in inbox
Fraud DetectionHigh Recall (~90%)Missing fraud costs moneyAccept investigating some legitimate transactions
Self-Driving CarsHigh Recall for obstaclesMissing a pedestrian is catastrophicAccept some false braking
Criminal JusticeHigh PrecisionWrongly convicting an innocent person is devastatingAccept some guilty going free

Why Accuracy Is Misleading

With 99% healthy patients and 1% sick:

The Precision-Recall Trade-off

Confusion Matrix is the essential diagnostic tool for classification models — revealing the specific failure modes that a single accuracy number hides, enabling practitioners to choose the right metric for their domain (precision vs recall), tune decision thresholds accordingly, and build models that fail in the least harmful way for their specific application.

confusion matrixprecisionrecall

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.