How to save to disk / export a lightgbm LGBMRegressor model trained in python?

Try:

my_model.booster_.save_model('mode.txt')
#load from model:

bst = lgb.Booster(model_file="mode.txt")

Note: the API state that

bst = lgb.train(…)
bst.save_model('model.txt', num_iteration=bst.best_iteration)

Depending on the version, one of the above works. For generic, You can also use pickle or something similar to freeze your model.

import joblib
# save model
joblib.dump(my_model, 'lgb.pkl')
# load model
gbm_pickle = joblib.load('lgb.pkl')

Let me know if that helps

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)