optuna_integration/lightgbm-tuner-cv-regression-stratified
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Optuna Integration | error | none, edit by hand | All versions |
LightGBMTunerCV defaults to stratified=True, so running it with a regression objective passes continuous targets to StratifiedKFold inside lightgbm.cv and fails every trial with ValueError.
tuner = LightGBMTunerCV({"objective": "regression", "metric": "rmse"}, dtrain, nfold=5)tuner = LightGBMTunerCV({"objective": "regression", "metric": "rmse"}, dtrain, nfold=5, stratified=False)What the rule reports
Section titled “What the rule reports”Calls to LightGBMTunerCV with a literal regression objective in params that neither set stratified=False nor pass an explicit folds= splitter.
How to fix it
Section titled “How to fix it”Pass stratified=False (or an explicit folds= cross-validation splitter such as KFold or TimeSeriesSplit).
Diagnostic message
Section titled “Diagnostic message”LightGBMTunerCV defaults to stratified=True, which fails on regression objectives because LightGBM tries to stratify continuous targets. Pass stratified=False or an explicit folds= splitter.See all rules in the Optuna Integration pack.