Search code examples
pythonlightgbm

LGBMClassifier has no attribute apply - Probability Calibration


I am trying to calibrate the LGBM probabilities by using the end-nodes(leaves).

I am following this link :

Probability Calibration

However, I am unable to add the apply function on the fit LGBM model.

I keep getting the error :

'LGBMClassifier' object has no attribute 'apply'

I tried to look through the documentation and it seems like I am missing something.

Can someone help me out with this please?


Solution

  • Guess, linked blog post might be based on initial versions of Lightgbm.

    In current version (3.1.0), we can get leaf index using predict method.

    lgb.predict(..., pred_leaf = True) , default value is False.

    Works with both sklearn wrapper classes (LGBMClassifier) & import lightgbm as lgb.

    Attaching Lightgbm documentation links for reference