Skip to content

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)

Calls to LightGBMTunerCV with a literal regression objective in params that neither set stratified=False nor pass an explicit folds= splitter.

Pass stratified=False (or an explicit folds= cross-validation splitter such as KFold or TimeSeriesSplit).

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.