Key Takeaways: Chapter 17

Class Imbalance and Cost-Sensitive Learning


  1. Every interesting classification problem in the real world is imbalanced. Churn (8%), fraud (1-2%), equipment failure (0.4%), disease detection, conversion prediction --- the event you are trying to predict is almost always the minority class. If you build models without accounting for imbalance, you build models that predict the majority class and call it a day. The imbalance ratio tells you how severe the problem is, and the cost ratio tells you what to do about it.

  2. Accuracy is not just useless for imbalanced problems --- it is dangerous. A model that predicts "no churn" for every subscriber achieves 91.8% accuracy. A model that predicts "no equipment failure" for every reading achieves 99.6% accuracy. These numbers create false confidence in systems that catch none of the events that matter. Use AUC-PR, precision, recall, and business cost metrics instead.

  3. Threshold tuning is the most underrated technique for imbalanced classification. Every probability-producing classifier uses a default threshold of 0.50, which is optimal only when false positives and false negatives cost the same amount. They almost never do. Lowering the threshold from 0.50 to the business-optimal value requires no retraining, no new libraries, and no changes to the model. It often produces larger improvements in business value than any resampling technique.

  4. The cost matrix drives every decision. Define the cost of a false negative (missed event) and a false positive (unnecessary action). Compute the break-even precision: FP_cost / (FP_cost + FN_cost). If the break-even precision is 2.7% (StreamFlow) or 1% (TurbineTech), you know the model should aggressively predict the positive class. If it is 30%, you need to be more selective. The cost matrix answers "how aggressive should we be?" before you touch any code.

  5. SMOTE creates synthetic minority examples by interpolation, not duplication --- but it helps tree-based models less than you think. SMOTE generates points along line segments between nearest minority-class neighbors. This is geometrically meaningful for linear models and distance-based models. Decision trees split on axis-aligned thresholds and care about purity gain, not geometric placement. For gradient boosting and random forests, class_weight or sample_weight often achieves similar results to SMOTE with less complexity.

  6. SMOTE must be applied inside cross-validation, never before it. Applying SMOTE to the full training set before splitting into folds causes data leakage: synthetic examples derived from one fold may be nearly identical to real examples in another fold. Use imblearn's Pipeline to ensure resampling happens only within the training portion of each fold.

  7. class_weight='balanced' implicitly assumes the cost ratio equals the imbalance ratio. For StreamFlow (11:1 imbalance, 36:1 cost ratio), balanced weights underestimate the true cost asymmetry. For a problem where the imbalance ratio exceeds the cost ratio, balanced weights overestimate. Calculate your actual cost ratio and use custom sample_weight when the two ratios diverge.

  8. Low precision can be highly profitable. StreamFlow's threshold-tuned model has 18% precision --- 82 out of 100 flagged subscribers were not going to churn. But each wasted $5 offer costs nothing compared to the $180 saved when a real churner is retained. TurbineTech's model has 6% precision, and it saves $51 million annually. Always compute the return on investment, not just the precision rate.

  9. When cost asymmetry is extreme, combine cost-weighted training with threshold tuning. Cost weights improve the model's ranking quality by making it pay more attention to the minority class during training. Threshold tuning converts the improved ranking into a cost-optimal decision boundary. Neither technique alone is as effective as both together. TurbineTech's combined approach caught 93.6% of failures --- better than either technique individually.

  10. Always disaggregate imbalance analysis by subgroup. When the positive rate varies across demographic or operational segments, a single threshold produces unequal performance. Hospital readmission rates vary by insurance type. Churn rates vary by plan tier. Equipment failure rates vary by turbine model. A model that achieves 90% recall overall may achieve 95% for one group and 75% for another. Check this before deployment.


If You Remember One Thing

The default threshold of 0.50 is almost never correct for imbalanced problems. It assumes that false positives and false negatives cost the same amount, which is true in textbook examples and almost never true in practice. Missed churners cost $180; wasted offers cost $5. Missed equipment failures cost $500,000; unnecessary inspections cost $5,000. The optimal threshold follows directly from the cost ratio, and it is often far below 0.50. Before you reach for SMOTE, before you tune class weights, before you try any sophisticated technique --- compute the business-optimal threshold. It is the highest-impact, lowest-effort intervention for any imbalanced classification problem.


These takeaways summarize Chapter 17: Class Imbalance and Cost-Sensitive Learning. Return to the chapter for full context.