-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[R-package] session crashes when serializing and deserializing model #4415
Comments
It is hard to say for sure since you haven't provided a reproducible example showing exactly what you tried, but based on the information you've provided, #4208 probably describe problems you're facing using Until then, you can use the functions You can try these by using the following code: library(lightgbm)
data(agaricus.train, package = "lightgbm")
dtrain <- lightgbm::lgb.Dataset(
agaricus.train$data
, label = agaricus.train$label
)
bst <- lightgbm::lgb.train(
params = list(
"learning_rate" = 0.05
)
, data = dtrain
, nrounds = 10L
, obj = "binary"
)
model_file <- "test-model.rds"
saveRDS.lgb.Booster(
object = bst
, file = model_file
)
rm(list = ls()) After running that code, restart your R session and re-load the model. You should see that you're able to successfully predict on new data. library(lightgbm)
model_file <- "test-model.rds"
data(agaricus.test, package = "lightgbm")
bst <- lightgbm::readRDS.lgb.Booster(
file = model_file
)
preds <- predict(bst, data = agaricus.test$data)
print(preds) For more, see:
NOTE: I'm not familiar with how |
that's correct! just the issue I was having. Thanks for the workaround! Sadly, the code you provided crashed my R environment |
How did you install If you need further help, please provide a reproducible example. |
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one. Thank you for taking the time to improve LightGBM! |
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
I trained a model in R using LightGBM (treesnip) and saved using common saveRDS command.
To my surprise, when trying to predict some data after reading the saved model, readRDS seems to work but script&predict is crashing.
Read this issue #4208 regarding some similar issue but I am not sure that is the cause.
is there any safe procedure to save my model fot later use in R?
regards
The text was updated successfully, but these errors were encountered: