Skip to content

lightgbm/removed-training-keyword

Rule removed-training-keyword
Pack LightGBM
Severity error
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions LightGBM 4.0 and later

LightGBM 4.0 removed the early_stopping_rounds, verbose_eval and fobj keywords from train() and cv(), and evals_result from train(). It also removed early_stopping_rounds and verbose from estimator fit(). LightGBM 4.6 removed feature_name and categorical_feature from train() and cv().

lgb.train(params, train_set, valid_sets=[valid_set], early_stopping_rounds=10)
lgb.train(params, train_set, valid_sets=[valid_set], callbacks=[lgb.early_stopping(10)])

Use callbacks for early stopping, periodic logging and evaluation history. Keep any existing callbacks when adding early_stopping(), log_evaluation() or record_evaluation(history). For a custom objective, pass the callable as params["objective"]. Configure feature names and categorical features on the Dataset.

early_stopping_rounds is still accepted as an alias for the early_stopping_round setting inside params.

On a current API, the unsafe fix removes the literal no-op keywords fobj=None and verbose_eval=False from native calls and verbose=False from estimator fit(). Migrate the remaining calls by hand to preserve the intended stopping criterion, logging, evaluation history, objective or dataset metadata. Omit estimator verbose=False when you want no evaluation logging. To enable evaluation logging, add log_evaluation() to the callbacks.

4.0 release notes | 4.6 release notes | Parameter reference

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

LightGBM 4.0 removed this keyword from train() and cv(). Omit fobj=None or verbose_eval=False on the current API.

Browse the other rules of the LightGBM pack.