ML basics
Class imbalance
When the interesting class is rare, sample, weight and measure accordingly.
What it is and why it exists
Attacks, fraud, hallucinations and escalation-worthy tickets are rare. Models and judges trained or tuned naively predict the majority class. Use stratified evaluation sets, class weights, oversampling the rare class for labelling, and metrics that don’t hide it.
Quick prototype
—
In production, at scale
Eval sets with enough rare-class examples to measure recall, per-class metrics, and thresholds chosen from the cost of misses.
Vendors and tools
| imbalanced-learn | Resampling tools |
|---|
How it fails
- An eval set with three failure examples
What the interviewer asks next
Your judge agrees with humans 94% of the time. Enough?
Check its true-negative rate on the failures — with 6% failures, a judge that always says pass agrees 94% of the time.