Class weights vs resampling for imbalance — which do you reach for first?
easyAnswer
- Class weights (or a weighted loss) first — they're a one-line change, preserve the dataset, don't discard data or synthesize points, and often match resampling in accuracy.
- If class weights aren't enough (extremely rare positives, non-linear boundary near the minority), try SMOTE variants for oversampling.
- Combine with threshold tuning at inference for full control.
- Real answer for tabular data with mild imbalance: ='balanced' + threshold tuning is usually enough.
Check yourself — multiple choice
- Always resample first
- Try class weights + threshold tuning first; escalate to SMOTE variants if still insufficient
- Never use class weights
- Undersample as a default
Class weights + threshold tuning is the cheap first line; escalate to SMOTE if needed.
#imbalance
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- When should you use PR-AUC instead of ROC-AUC?
- How do you handle class imbalance in a dataset?
- Why is the base rate of the positive class critical to know?
- How do class weights work in logistic regression, and when do you use them?
- You trained Naive Bayes on balanced data but deploy on data where positives are 1%. What happens and what do you do?
- How do you handle class imbalance in XGBoost / LightGBM?