Contents
Imbalanced Data/Chapter 09 of 09
09Summary
- What goes wrong. The loss has one term per example, so the common class dominates. For logistic regression, \frac1n\sum_ip_i=n_+/n: the scores sit near the fraud rate, and threshold 0.5 flags only 56\% of the frauds.
- Balance the data. Undersampling throws data away and is unstable; oversampling copies and adds nothing new; SMOTE creates x+\lambda(x_{\mathrm{nb}}-x) between neighboring minority points. Recall 56\%\to84\%.
- Class weights. L_w=-\sum_ic_{y_i}[\dots] with c_1=w: a weight w is exactly w copies. Recall 86\%, but false positives 45\to4{,}703, and the weighted model changes its slopes, not just its intercept.
- Fix the scores. The balanced model learned a 50/50 world. Undo it: \operatorname{logit}p=\operatorname{logit}p_{\mathrm{bal}}-\ln w (divide the odds, not the probability). Then flag when p\ge\tau^*=C_{\mathrm{FP}}/(C_{\mathrm{FP}}+C_{\mathrm{FN}}), here 4\%. Recall 80\% with 354 false positives.
- Follow-ups. Try the threshold before rebalancing; resample after the split, inside the training folds; report the precision–recall curve or the cost, never accuracy.