Calling XGBModel.fit() should clear the Booster by default #6562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #6536
Calling
fit()
twice with a scikit-learn model object should cause the model to be cleared, e.g.Expected output:
Currently, XGBoost will automatically pick up the existing Booster object and use it as a checkpoint:
This behavior is not desired for most use cases of scikit-learn. For example, scikit-learn's cross-validation method will call
fit()
multiple times, with the expectation that the underlying model to be cleared for every invocation offit()
.This PR fixes the behavior of
fit()
as follows:fit()
will clear any existing model. This behavior is now documented in the docstring offit()
.xgb_model
to resume training from a checkpoint.xgb_model
parameter can now beXGBModel
object.