xgboost/removed-fit-keywords
| Rule | removed-fit-keywords |
|---|---|
| Pack | XGBoost |
| Severity | error |
| Fix | none, edit by hand |
| Library versions | XGBoost 2.1 and later |
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.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
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.Browse the other rules of the XGBoost pack.