Closed jinlow closed 9 months ago
@gravesee Adding the ability to pickle a booster, just wanted to run by you, that you didn't see any footguns with this?
The Booster
object itself can't be directly pickled because it's just a reference to something in memory, so I am dumping the model, and then reloading from that json dump.
Only thing I'd try different is dumping the file to bytesio (if that is supported) instead of having to write a file, but otherwise looks good to me
Good callout yeah, I don't think that's possible, just because you can only pass a string path to the rust side to use as a file path to save.
Ah yeah, I forgot about that. Can rust return bytes, though? From the serde deserialization?
Good question! I can look at that, that would be good to have, as a save load option. And then would make dealing with python file like objects easier.
Actually, I could use the from_json
and json_dump
methods directly as well. Rather than the save and load methods.
The nice thing about bytes is that they're pickleable. that was my original motivation but definitely not a requirement!
OK, this seems cleaner, thanks for the suggestion!
Fixes max leaves bug #32 and makes the booster pickleable.