Closed faithfulalabi closed 1 year ago
Hi! That's currently not possible and I probably won't support it in the future either. It makes the implementation much simpler to load the model.txt instead of loading a pickled model :) Pickle is very Python specific, and I'm considering rewriting lleaves from scratch in Cpp.
You could try storing the model.txt in an in-memory tmp-file, using code roughly like this:
import lightgbm as lgb
import tempfile
with tempfile.NamedTemporaryFile(mode='w+b', delete=False, suffix='.txt') as tmp_file:
model.save_model(tmp_file.name)
print(f"Model saved to: {tmp_file.name}")
loaded_model = lleaves.Model(tmp_file.name)
Thanks for the fast response and sample code. Was going to do that as a work around but thought I'd ask first. Thanks again 😄
lleaves.Model
function?