Open BastienFR opened 2 months ago
Thanks for using LightGBM.
The answer to this question will depend on your answers to those questions.
And can you please edit the description as follows?
Thanks for your response.
what version of R was the model file created with? what version of LightGBM?
Both those questions are hard to answer as I don't keep track of the version of neither R or my packages when I run a code. The objects date from before 2023, therefore I can expect R to have been around version 4.2. and lightgbm at version 3.3.. It's the best I can do, sorry.
About the formatting, sorry about the doubling of the first sentence, it's a copy-paste error that happened after I reread my post. As for the screenshots, I don't want to get into an argument here. I know my question wasn't up to standard. Print screens are to avoid and reproducible example that are easily copy-pasted and machine readable is what to aim for. However, I work in a corporate environment that as no other way out but screenshots. It was pretty much that or nothing. Making a reproducible example would imply building two different environments, one old to save a model and one new to read it, which is time consuming. I (wrongly?) expected my question to be relatively strait forward and simple and a direct consequence of deprecating readRDS.lgb.Booster()
. Feel free to close this issue if you disagree with me or if the description and answers I provided you are not sufficient to understand the problem.
Both those questions are hard to answer as I don't keep track of the version of neither R or my packages when I run a code.
Ok thanks. When I have time to look at this again, I'll try to create a reproducible example for you using R 4.2.0 and {lightgbm}
3.3.1.
If you plan on using .rds
for long-term storage of any R objects, you should keep track of this information. It is possible that a future version of R will not be able to read .rds
objects produced by an older version.
See:
version
arg at https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/readRDSI work in a corporate environment that as no other way out but screenshots
It's fine. I manually retyped the code from your screenshots. It took me just 30 seconds, and now this issue will be discoverable by others facing the same problem and searching for those error messages.
Description
I have a long term project that uses
lightgbm
for the modeling. I made a bunch of models throughout the years which I access again from time to time to predict on new data. I used to save my models withlightgbm::saveRDS.lgb.Booster()
and read them withlightgbm::readRDS.lgb.Booster()
. I’m trying to run the code withlightgbm
version 4.3.0, and now my code fails telling me thelightgbm::readRDS.lgb.Booster()
doesn’t exist anymore:I’ve found in this issue (https://github.com/rstudio/bundle/issues/55) that the function was remove and that we should use
readRDS
instead. When I do so, the model is loaded with no error:However, the object created is unusable:
Is there a way to load old model created with
lightgbm::saveRDS.lgb.Booster()
back into the new version of lightgbm? I guess either by makingreadRDS
works with files created withsaveRDS.lgb.Booster()
or add back thelightgbm::readRDS.lgb.Booster()
into the package for this kind of use cases?Rerunning all my old models would be difficult and downgrading my version of lightgbm do not sound ideal either.
Reproducible example
See print screen above. Sorry I work in a close environment and can't export objects or code.
Environment info
LightGBM version 4.3.0 install from CRAN, working in R 4.4.0 on a windows machine