| Predicted Positive | Predicted Negative | |
| True Positive |
TP
170
|
FN
30
|
| True Negative |
FP
37
|
TN
163
|
The Confusion Matrix is the foundation of all classification metrics. It breaks down predictions into four categories based on true vs. predicted class:
• True Positives (TP): Correctly predicted positive class
• True Negatives (TN): Correctly predicted negative class
• False Positives (FP): Incorrectly predicted positive (Type I error, "false alarm")
• False Negatives (FN): Incorrectly predicted negative (Type II error, "missed detection")
Key Metrics Derived from the Confusion Matrix:
1. Sensitivity (Recall, TPR): Fraction of actual positives correctly identified. Formula:
2. Specificity (TNR): Fraction of actual negatives correctly identified. Formula:
3. Precision (PPV): Fraction of positive predictions that are correct. Formula:
4. Accuracy: Overall fraction of correct predictions. Formula:
5. F1-Score: Harmonic mean of precision and recall. Formula:
6. Balanced Accuracy: Average of sensitivity and specificity. Formula:
The Accuracy Paradox: With the melanoma dataset (99.5% benign), a classifier that always predicts "benign" achieves 99.5% accuracy but 0% sensitivity—it misses all cancers! This demonstrates why accuracy alone is insufficient. Balanced accuracy (50%) and F1-score (0%) correctly reveal this model's failure.
Threshold Selection Trade-off: Moving the decision threshold creates a fundamental trade-off between sensitivity and specificity. Lower thresholds predict more positives (higher sensitivity, lower specificity); higher thresholds predict fewer positives (lower sensitivity, higher specificity). The optimal threshold depends on the relative costs of false positives vs. false negatives in your application.