-
-
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
Proper way to serialize XGBoost model without exporting to a file #7351
Comments
According to https://www.rdocumentation.org/packages/xgboost/versions/1.4.1.1/topics/a-compatibility-note-for-saveRDS-save, you should use |
Aren't we a bit too quick here with closing this?
|
I am using xgboost_1.4.1.1 in R.
Assume I have this model:
How do I serialize this model correctly without writing to disk?
I know the documentation is explicit to not use
saveRDS()
orserialize()
on thebst
object, and rather usexgboost::xgb.save()
. Butxgboost::xgb.save()
can only write to a file.If I do
I get a strange error:
caused by
handle <- xgb.Booster.handle(modelfile = modelfile)
withinxgboost::xgb.load()
.Looking into the xgboost R source, the following way seems to work well for loading the
raw
model:Note the unfortunate use of
:::
.Can someone advise whether this is the correct way, and if so, whether
xgboost::xgb.load()
should be fixed? I think theif
-structure should be changed to:and
handle <- xgb.Booster.handle(modelfile = modelfile)
should be moved to theelse
block?The text was updated successfully, but these errors were encountered: