lightgbm/removed-training-keyword
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| LightGBM | error | unsafe, with xpd check --fix --unsafe-fixes |
LightGBM 4.0+ |
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)])How to fix it
Section titled “How to fix it”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
Diagnostic message
Section titled “Diagnostic message”LightGBM 4.0 removed this keyword from train() and cv(). Omit fobj=None or verbose_eval=False on the current API.See all rules in the LightGBM pack.