LightGBM - get_labels() attribute error

Hello Everyone,

I am trying to build a model in light gbm for regression. I am trying to fine tune the parameters using for loops for n_estimators.
While using custom_eval function while fitting, for RMSLE getting error as below:
AttributeError: ‘numpy.ndarray’ object has no attribute ‘get_label’

Can some one please help me in this.
Below is the custom eval function

def custom_eval(preds, dtrain):
labels = dtrain.get_label() ## error for this line.
preds = preds.clip(min=0)

return [('rmsle', np.sqrt(msle(labels, preds)))]

Thank you,
BS

© Copyright 2013-2021 Analytics Vidhya