jinlow / forust

A lightweight gradient boosted decision tree package.
https://jinlow.github.io/forust/
Apache License 2.0
56 stars 6 forks source link

Fix/max leaves #81

Closed jinlow closed 9 months ago

jinlow commented 9 months ago

Fixes max leaves bug #32 and makes the booster pickleable.

jinlow commented 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?

jinlow commented 9 months ago

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.

jinlow commented 9 months ago

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.

gravesee commented 9 months ago

Ah yeah, I forgot about that. Can rust return bytes, though? From the serde deserialization?

jinlow commented 9 months ago

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.

jinlow commented 9 months ago

Actually, I could use the from_json and json_dump methods directly as well. Rather than the save and load methods.

gravesee commented 9 months ago

The nice thing about bytes is that they're pickleable. that was my original motivation but definitely not a requirement!

jinlow commented 9 months ago

OK, this seems cleaner, thanks for the suggestion!