lightgbm/cv-regression-stratified
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| LightGBM | error | none, edit by hand | All versions |
lightgbm.cv defaults to stratified=True. Passing a regression objective with continuous targets raises ValueError: Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead..
result = lgb.cv({"objective": "regression"}, train_set, num_boost_round=50)result = lgb.cv({"objective": "regression"}, train_set, num_boost_round=50, stratified=False)What the rule reports
Section titled “What the rule reports”Calls to lightgbm.cv whose parameter dictionary sets a regression objective (regression, l1, l2, rmse, mae, huber, fair, poisson, quantile, mape, gamma, or tweedie) without stratified=False or explicit folds=.
How to fix it
Section titled “How to fix it”Pass stratified=False for continuous targets, or pass an explicit time- or group-aware folds= splitter.
Diagnostic message
Section titled “Diagnostic message”lightgbm.cv defaults to stratified=True, which raises ValueError("Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead.") on regression objectives. Pass stratified=False.See all rules in the LightGBM pack.