How do you handle class imbalance in XGBoost / LightGBM?
mediumAnswer
- Set (for binary) so gradients from the minority class are up-weighted.
- Alternatively use in LightGBM.
- This adjusts the loss weighting without changing the data.
- Combine with a probability-based threshold tuned on validation for the actual decision.
- If you also need calibrated probabilities, apply post-hoc calibration since distorts them.
Check yourself — multiple choice
- Duplicate the minority class rows
- Set and tune the decision threshold on validation
- Change the tree-splitting algorithm
- Drop the majority class
rescales gradients — tune the decision threshold on validation.
#xgboost#lightgbm#imbalance
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- How do XGBoost, LightGBM, and CatBoost each handle categorical features?
- What are monotonic constraints in XGBoost / LightGBM and when do you use them?
- Rule of thumb: when do you pick XGBoost vs LightGBM vs CatBoost?
- 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?