-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re-use of same model automatically continues training even if not desired #6536
Comments
I made the change with bug fixing in mind. It's unusual to load a model just to train it from fresh start. Bug fixes are breaking change but in a good way, so I didn't make a big announcement. But suggestions are welcomed. cc @hcho3 . |
Also this ca3da55 will get training continuation with early stopping working. |
The bug fixes in the PR are fine, assuming user wants to continue training is not |
As it isn't documented nor specified in any skl guide line (so far I haven't found, feel free to correct me), I have to make an assumption when users call
I prefer second one ... I can make a patch to revert the behavior on 1.3, but still want to keep it on master for next release.
To me that's quite reasonable thing to do instead of calling it "workaround". If you want to fit a new model, initiating a new object makes sense. params = old_reg.get_params() # Or if you save the parameters via other means.
new_reg = xgb.XGBRegressor()
new_reg.set_params(params)
new_reg.fit(X, y) |
@trivialfis ca3da55 is not part of 1.3, so we didn't break 1.3 here. |
@hcho3 Oops, didn't look into the history. Thanks for reminding. Also, WDYT? |
FYI I'm definitely good with making continued training easier, it's just a surprising change. It would be good to have a bool to pass if one wants to continue training, instead of assuming. If I'm mistaken and this is what @hcho3 expects from xgboost in first place, then I can accept and just alter my usage. |
Got it. Let me put a breaking notice on 1.4 roadmap. Thanks for you feedback. Instead of adding another parameter, I want to deprecate the parameter |
@trivialfis @pseudotensor Here is my take on this matter: In scikit-learn API, the expectation is that calling |
Thanks for the reference. Em ... training continuation on xgboost doesn't exactly match the partial fit, as we should not do mini batch with xgboost natively. |
@trivialfis Let's keep |
If we make it explicit that existing model will be disregarded then I'm fine with it. Before that breaking change, the existing model is always silently ignored. |
To me that's quite surprising. |
@trivialfis Got it. Let's explicitly document that calling |
Also, if we keep that parameter we will have 2 conflicting sources of input model. So we need to somehow inform users the model loaded by |
Got it. I will open a PR tomorrow. |
@pseudotensor Do you agree with my description of how |
Yes, thanks. |
@trivialfis , just by changing nightly we found the continuation commit broke some things.
125b3c0 is good
ca3da55 is bad
Issue is that before one had to pass xgb_model explicitly to continue training, but now it always happens, ruining 'best iterations".
In original training we see:
Then after loading pickled state and fitting freshly we see:
This can be mimicked by loading from the pickled state and then also re-establish the model from a bare class and compare.
That is, the pickle loaded state should just load the model, and model.fit should be same as fresh case, but instead it (without us asking) continues off the original fit case and has best_iterations=0. This makes things like asking how many iterations are 'best' all wrong, since now it would say 0.
Previously one only got continued training if explicitly passing xgb_model, but not I think the code passes "model" always, which is a problem.
We are working around this by re-instantiating the model from params + class, but I don't think this should be required. It's certainly a breaking change if it was done.
glmpklissue.zip
The text was updated successfully, but these errors were encountered: