3

I have trained a lgbm model in sklearn API format just like this:

cb_classifier = LGBMClassifier(**params)


cb_classifier.fit(X_train[features],
                  y_train,
                  eval_set = (X_validation[features], y_validation),
                  categorical_feature = cat_dims
                  )

After the model was generated, I obtained the predictions for X_test with that model, but now I would like to obtain the same model for predicting the results in the native LGBM format, like:

native_lgbm_model.predict(X_test)

I tried saving the cb_classifier with booster like this:

cb_classifier.booster_.save_model("path/booster_lgbm.txt")

native_lgbm_model = lightgbm.Booster(model_file='path/booster_lgbm.txt')

But when trying to predict the results they were different from the results obtained when predicting with the sklearn API.

Is there any way to convert cb_classifier into native LGBM model?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
jartymcfly
  • 1,945
  • 9
  • 30
  • 51

0 Answers0