Classification Evaluation (Confusion Matrix and Metrics)
Context: FIT1043_MOC Β· how good is a classifier? Β· counts outcomes in a confusion matrix Β· the right metric depends on the cost of each error
Quick Revision
- π― Objective: score a classifier β build a confusion matrix (TP/FP/FN/TN), then compute the metric that matches the task.
- π¦ Core Components: accuracy | sensitivity/recall | specificity | precision | false-positive rate.
- β‘ Key Constraint: accuracy alone misleads β choose the metric by which error is worse (a missed fraud vs a blocked good email).
π How It Works
1. The Confusion Matrix
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actual Positive | TP (true positive) | FN (false negative) |
| Actual Negative | FP (false positive) | TN (true negative) |
2. The Five Metrics
- Accuracy β overall correct: .
- Sensitivity / Recall β of actual positives, how many caught: .
- Specificity β of actual negatives, how many correct: .
- False Positive Rate β of actual negatives, how many wrongly flagged: .
- Precision β of predicted positives, how many correct: .
3. Which Metric When (it depends)
- Spam filter β optimise precision / specificity β a FN (spam in inbox) is tolerable; a FP (good mail blocked) is costly.
- Fraud detector β optimise sensitivity/recall β a FP (normal flagged) is tolerable; a FN (missed fraud) is costly.
- Covid test β balance sensitivity (catch the sick) vs specificity (donβt alarm the healthy).
βοΈ Core Decision Matrix
| Metric | Question it answers | Formula |
|---|---|---|
| Accuracy | overall how often correct? | |
| Recall (sensitivity) | of actual +, how many found? | |
| Specificity | of actual β, how many correct? | |
| Precision | of predicted +, how many right? |
When It Flips: recall and precision pull apart β flagging everything positive gives perfect recall but poor precision; flagging only sure cases gives high precision but poor recall. The task's error costs pick which to favour.
π Exam Execution Trace
Applied Exercise
Problem: , , , . Compute accuracy, recall, precision. Derivation Proof / Hand-Calculation Walkthrough:
Final Extracted Output: 70% accurate; catches 80% of positives (recall) but only 67% of its positive calls are right (precision).
π§ Active Recall
For a fraud detector, which metric matters most and why β precision or recall?
- Hint: Cost of a false negative.
Answer
- Short answer: Recall (sensitivity) β a missed fraud (false negative) is far costlier than a false alarm (false positive), so you maximise the fraction of actual frauds caught.
- Why: Error asymmetry β recall penalises misses; the tolerable error (FP) is what precision would protect.
Why can a 95%-accurate classifier still be useless?
- Hint: Class imbalance.
Answer
- Short answer: If 95% of cases are negative, always predicting βnegativeβ scores 95% accuracy yet catches zero positives (recall 0); accuracy hides this.
- Why: Imbalance β inspect recall/precision on the positive class, not overall accuracy.