I'm trying to use BaggingRegressor from scikit-learn together with LightGBMRegressor and Mean Absolute Error objective and I'm receiving nan outputs. I reproduced the problem below.

Python version: 3.6.7 LightGBM version: 2.2.2 Sklearn version: 0.20.2

from sklearn.ensemble import BaggingRegressor
from lightgbm.sklearn import LGBMRegressor
from sklearn.datasets import fetch_california_housing

data = fetch_california_housing()

X = data['data']
y = data['target']

model = BaggingRegressor(LGBMRegressor(objective='mse'))

model.fit(X, y)


array([4.22873518, 4.00953178, 4.22808261, ..., 0.8777045 , 0.93616599,

Bagging with Mean Absolute Error (MAE) objective/criterion

model = BaggingRegressor(LGBMRegressor(objective='mae'))

model.fit(X, y)


array([nan, nan, nan, ..., nan, nan, nan])

while Random Forest with MAE returns proper output:

model = BaggingRegressor(RandomForestRegressor(n_estimators=10, criterion='mae'))

model.fit(X, y)

returns proper output

array([4.397593 , 3.9600914, 3.8033813, ..., 0.88761  , 0.881185 ,
       0.92282  ])

Do you know what may cause it? Is it possible to fix it or just I should post an issue on scikit-learn?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.