-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[python-package] Model parameters are lost when loading Booster from model serialized string #6851
Comments
This fixes microsoft#6851 by using the same workaround as when loading the model from a file.
Thanks for using LightGBM. I believe this issue is a duplicate of #5539 and #6821, both of which will be fixed by #6101. There the issue was about "copying", but it is the same root cause because copying a |
Hello, @jameslamb . Thank you for your feedback. I encountered this issue when saving the string to a database as a CLOB for future use. When I wanted to use the |
…y string Test case for microsoft#6851
This fixes microsoft#6851 by using the same workaround as when loading the model from a file.
Even after #6852 and #6101 are merged, it will still be a while (on the order of maybe 1-4 months) until there's another release of If you don't want to wait that long or have to build Then you could retrieve both at the same time and pass the
#6852 helps! I've already prioritized #6101 and assigned it to myself, will get it into the next release. Sorry it's taken so long... a lot of things in |
That is ok. I devised a workaround in my client code around the lines of: # Workaround for LightGBM matched by version
from packaging.version import Version
from lightgbm import __version__ as lgb_version
...
# Workaround a bug in LightGBM python package when loading from string
if Version(lgb_version) <= Version("5.0.0"):
self.model.params = self.model._get_loaded_param() And it works! I can wait until next release. But want to make sure it will be there :)
As all good software does :) Feel free to undo some of my workaround code when it is fixed for good. |
Description
After training, saving the model on a string, then retrieving it, the
params
dictionary are lostReproducible example
Environment info
LightGBM version or commit hash: 4.6.0
Command(s) you used to install LightGBM
ArchLinux system
Additional Comments
I think the fix is pretty simple and stems from the
__init__()
function last line where theparams
member is overwritten with whatever is passed (empty, when loading from a serialized string)I guess the fix is easy, will PR it in a moment.
The text was updated successfully, but these errors were encountered: