Search code examples
pythonpython-2.7machine-learningregressionlightgbm

lightgbm.sklearn.LGBMRegressor failed to fit simple line


I'm pretty new with LightGBM and I'm trying to fit simple line via LGBMRegressor.

import numpy as np
import lightgbm as lgbm
xs = np.linspace(0, 10, 30).reshape((-1, 1)) 
ys = np.linspace(0, 10, 30)    
reg = lgbm.sklearn.LGBMRegressor()
reg.fit(xs, ys) 
print reg.predict(xs)
>>> array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
    0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
    0.,  0.,  0.,  0.])

What i'm doing wrong? Maybe i need more features?

My LightGBM version is 2.0.7 (from github source), python version is 2.7.12

PS Sorry for my poor English


Solution

  • Set parameters min_data_in_leaf = 1, min_data_in_bin = 1.