Skip to content

XGBoost

The XGBoost pack has 7 rules, and xpd can fix 2 of them.

The XGBoost pack checks the native Python API and the scikit-learn estimators against the XGBoost 3.4.2 documentation.

Rule Severity Fix What it finds
removed-fit-keywords error none XGBoost 2.1 removed eval_metric, early_stopping_rounds and callbacks from the scikit-learn estimator's fit method.
removed-gpu-hist error unsafe XGBoost 3.1 removed the gpu_hist tree method.
ineffective-max-quantile-batches warning safe XGBoost 3.3 deprecated max_quantile_batches and made it ineffective.
Rule Severity Fix What it finds
quantile-eval-without-train-ref error none XGBoost train requires a separate QuantileDMatrix or ExtMemQuantileDMatrix used for evaluation to reference the exact matrix passed as dtrain.
reused-early-stopping-callback warning none XGBoost's EarlyStopping callback stores training history and a count of rounds without improvement.
Rule Severity Fix What it finds
native-predict-after-early-stopping warning none XGBoost's native Booster.predict and Booster.inplace_predict use all retained rounds by default, including any rounds after early stopping found the best validation score.
dmatrix-rebuilt-for-predict warning none XGBoost's Booster.inplace_predict can score supported batches for tree boosters without allocating a new DMatrix for each batch.
  • ineffective-max-quantile-batches can remove a literal integer option.
  • removed-gpu-hist can migrate an estimator whose only option is the old tree method. This fix is unsafe because it changes the device setup.
  • Other configurations, reference changes, callback lifetimes and prediction choices require manual edits. Autofix verification checks that rewritten cases clear and that expected manual diagnostics remain.

The examples ran with the XGBoost CPU wheel at version 3.4.1 on 20 rows with two features. The GPU migration uses the documented parameter values.

Rule Observed result
removed-fit-keywords Each old keyword raised TypeError at fit. The three keywords worked together on the constructor.
removed-gpu-hist Estimator fit, native train and native cv rejected gpu_hist.
ineffective-max-quantile-batches Passing 1 produced the same cuts as the default and warned that the setting had no effect.
quantile-eval-without-train-ref The separate matrix raised ValueError. The evaluation list with the training matrix and a referenced validation matrix worked.
reused-early-stopping-callback The first fit retained four rounds. Reusing the callback retained one. A fresh callback again retained four.
native-predict-after-early-stopping The best iteration was 0 and the model retained four rounds. Predictions for the first round differed from full model predictions.
dmatrix-rebuilt-for-predict Native and in-place predictions agreed for a NumPy array and the DMatrix built from it.

Python API reference