Phase 2: Classical Machine Learning · 55 min · scikit-learn · pandas · matplotlib
The Concept
The Mindset Shift: From Aggregate to Slice
Leaderboard mindset: "raise the aggregate metric" -> random tuning, diminishing returns
Error-analysis mindset: "where and why does it fail?" -> targeted, high-impact fixes
The aggregate metric (overall accuracy, F1, AUC) is an average — it hides the distribution of errors. A model with 88% accuracy might be 99% accurate on the majority group and 60% accurate on a minority group that matters most. The aggregate says "good enough"; the slices say "here's where to focus."
Error analysis is the practice of systematically breaking down where the model fails and why. It replaces random hyperparameter tuning with targeted, high-impact fixes. The workflow is always the same two questions:
1. WHERE does it fail? -> slice the data; find subgroups with worse metrics
2. WHY does it fail? -> read actual errors; categorize the causes
The Four Categories of Failure
When you pull the actual misclassified examples and read them, failures typically fall into one of four categories:
- Mislabeled: the ground truth is wrong. Fix: correct the labels, add label verification.
- Edge case: the input is genuinely ambiguous or unusual. Fix: add features or training examples that cover this case.
- Model limit: the model architecture can't represent the pattern. Fix: increase capacity (more layers, deeper trees) or switch models.
- Data quality: the input features are corrupted, missing, or noisy. Fix: clean the data pipeline.
Once you've categorized the failures, rank them by impact = error_rate × slice_size × business_cost, and fix the highest-impact category first. This is how you go from "88% accuracy" to "95% accuracy on the segments that matter" — not by random tuning, but by understanding exactly what's broken.
Your spam classifier has 95% overall accuracy. But when you slice by email length, short emails (<50 chars) have only 72% accuracy. What should you do next?
The aggregate metric hides a weak slice. The next step is to pull the actual misclassified short emails, read them, and categorize why they fail (missing signal? ambiguous? mislabeled?). Then add targeted features or training examples. This is the core of error analysis: find the worst slice, understand the cause, fix it.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Build, Check Yourself, Key Terms & Next — plus a hands-on lab, quiz, and project artifact.
Create a free account — the opening phases of 29 of 35 courses are free, no credit card.