-1

I trained a LGBMClassifier model and saved it to a file thus:

clf = lgb.LGBMClassifier( ... )
clf.fit(X_train, y_train, **fit_params)
clf.booster_.save_model("model1.txt")

Now what I want is to re-use the saved model for probability predictions. But if I try:

## new predictions:

    clf_fs = lgb.Booster(model_file='model1.txt')
    y_pred2 = clf_fs.predict_proba(X_data2, num_iteration=clf_fs.best_iteration_)[:, 1]

I get this error:

AttributeError: 'Booster' object has no attribute 'predict_proba'

I understand that cls_fs is an object of class Booster and not of a class LGBMClassifier, and that I can use clf_fs.predict(), but not predict_proba. So how I can get back a LGBMClassifier object from the saved model file and generate proba predictions?

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Sachin Yadav
  • 748
  • 9
  • 28

1 Answers1

5

In the #1217 issue at Github on this, Guolin Ke, one of LightGBM core developers said:

booster.predict() actually will return the probabilities

so you shouldn't be needing predict_proba.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
desertnaut
  • 57,590
  • 26
  • 140
  • 166