Training logs are not being printed in LightGBM in Jupyter

Viewed 524

I am trying to train a simple LightGBM model on a Macbook but its not printing any logs even when verbose parameter is set to 1 (or even greater than 1)

param = {'num_leaves':50, 'num_trees':500, 'learning_rate':0.01, 'feature_fraction':1.0, 'tree_learner': 'serial', 'objective':'cross_entropy', 'verbose' : 1, 'metric':'kullback_leibler', 'is_training_metric':True}
model = lgb.train(param, train_data_lgbm)

I also changed is_training_metric to True as per another suggestion on Github. This also didn't lead to rectification. Can someone help with what I might be missing?

EDIT: I was running this code in Jupyter notebook. When I tried the same thing on terminal, it worked.
Can someone help with why am I not seeing logs on Jupyter notebook?

1 Answers

I don't know what kind of log you want, but in my case (lightbgm 2.2.3 on Colab not Jupiter notebook though), by adding valid_sets parameter to the train method, I was able to produce a logloss as shown below.

model = lgb.train(param, 
                  train_data_lgbm, 
                  valid_sets=[train_data_lgbm])

[1] training's xentropy: 0.606795.   
[2] training's xentropy: 0.579697.  
[3] training's xentropy: 0.513748.    
[4] training's xentropy: 0.494762.   
....   

If you want to produce a logloss for evaluation, you can display it in the following way.

eval_data_lgb = lgb.Dataset(X_test, y_test, reference=train_data_lgbm)
model = lgb.train(param, 
                      train_data_lgbm, 
                      valid_sets=[train_data_lgbm,
                                  eval_data_lgb])

[1] training's xentropy: 0.606795   valid_1's xentropy: 0.60837.    
[2] training's xentropy: 0.579697   valid_1's xentropy: 0.582659.    
[3] training's xentropy: 0.513748   valid_1's xentropy: 0.517523.    
[4] training's xentropy: 0.494762   valid_1's xentropy: 0.499277.  
....
Related