xgboost/removed-fit-keywords
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| XGBoost | error | none, edit by hand | XGBoost 2.1+ |
XGBoost 2.1 removed eval_metric, early_stopping_rounds and callbacks
from the scikit-learn estimator's fit method. Passing any of them there
raises TypeError.
model = xgb.XGBRegressor()model.fit(X_train, y_train, eval_set=[(X_valid, y_valid)], early_stopping_rounds=5)model = xgb.XGBRegressor(early_stopping_rounds=5)model.fit(X_train, y_train, eval_set=[(X_valid, y_valid)])What the rule reports
Section titled “What the rule reports”The rule follows an estimator to a constructor imported from XGBoost and
checks explicit keywords on its fit call.
How to fix it
Section titled “How to fix it”Move the options to the constructor or call set_params before fitting.
Keep eval_set on fit. When the same estimator is fitted again, check
which settings each call should use.
Diagnostic message
Section titled “Diagnostic message”XGBoost 2.1 removed eval_metric, early_stopping_rounds and callbacks from estimator fit. Set them in the constructor or with set_params and pass eval_set to fit.See all rules in the XGBoost pack.