Monday, February 13, 2017

LightGBM - accurate and fast tree boosing

Install


1. Open LightGBM github and see instructions. For windows, you will need to compiule with visual-studio (download + install can be done in < 1 hour)
2. use "pylightgbm" python package binding to run this code

Code example

import os
from pylightgbm.models import GBMRegressor

os.environ['LIGHTGBM_EXEC'] = "c:/.../LightGBM/windows/x64/Release/lightgbm"

model = GBMRegressor(
    num_threads=-1,
    learning_rate = 0.03,
    num_iterations = 5000, 
    verbose = False, 
    early_stopping_round = 50,
    feature_fraction = 0.8,
    bagging_fraction = 0.8,

model.fit(
    train_local[features].values, 
   train_local['loss'].values, 
    test_data = [(
        validation[features].values, 
        validation['loss'].values
    )]
)