Skip to content
Quantoros

Why can native Booster.predict disagree with sklearn predictions immediately after early stopping?

Classic MLLevel: IntermediateXGBoost · Prediction

Why can native Booster.predict disagree with sklearn predictions immediately after early stopping?

Hints
  • Training may retain rounds after the best score.
  • Check the exclusive endpoint of iteration_range.

Answer

The native interface may use all retained rounds, while sklearn uses best_iteration. Use the explicit half-open range (0, best_iteration + 1) or a correctly saved best model when comparing them.

Source and licence: XGBoost · Prediction · Apache-2.0 · answer: Quantoros editorial

Related questions