TransWikia.com

LightGBM get model decision(rules)

Data Science Asked by vamper1234 on April 15, 2021

I need to interpret the model decision for binary classification. Here is my model:

lgbm_params = {
    'application': 'binary',
    'boosting': 'gbdt'
    
}

# Fit the model
evaluation_results={}
clf = lgb.train(train_set=df_train,
                 params=lgbm_params,
                 valid_sets=[df_train, df_val],
                 valid_names=['Train', 'Test'], 
                 evals_result=evaluation_results
                 num_boost_round=500,
                 early_stopping_rounds=200,
                 verbose_eval=20
                )

I get all the leaf_values from the clf.dump_model()[‘tree_info’]

tree_index: 0
{'leaf_index': 0, 'leaf_value': -3.040727504018978, 'leaf_weight': 47528.00472457707, 'leaf_count': 1004195}
{'leaf_index': 13, 'leaf_value': -2.9202709057364595, 'leaf_weight': 1323.3580410331488, 'leaf_count': 26449}
{'leaf_index': 14, 'leaf_value': -2.9427631652658075, 'leaf_weight': 109.50735418498516, 'leaf_count': 2212}
{'leaf_index': 17, 'leaf_value': -1.4929745840872577, 'leaf_weight': 302.07093365490437, 'leaf_count': 1949}
{'leaf_index': 16, 'leaf_value': -2.9837542927288503, 'leaf_weight': 210.75128224492073, 'leaf_count': 4339}
{'leaf_index': 11, 'leaf_value': -3.066253913323111, 'leaf_weight': 48.197187930345535, 'leaf_count': 1030}
{'leaf_index': 19, 'leaf_value': -1.0782095500999522, 'leaf_weight': 121.46848337352276, 'leaf_count': 306}
{'leaf_index': 4, 'leaf_value': -1.0109852904649248, 'leaf_weight': 1215.3730453550816, 'leaf_count': 2287}
{'leaf_index': 10, 'leaf_value': -2.5625965199023018, 'leaf_weight': 176.44212743639946, 'leaf_count': 2928}
{'leaf_index': 5, 'leaf_value': -2.795752338152544, 'leaf_weight': 2099.699764251709, 'leaf_count': 39486}
{'leaf_index': 2, 'leaf_value': -0.9452821425348215, 'leaf_weight': 3836.4817948788404, 'leaf_count': 4829}
{'leaf_index': 15, 'leaf_value': -2.5710742313240202, 'leaf_weight': 70.22461323440075, 'leaf_count': 1171}
{'leaf_index': 7, 'leaf_value': -2.003150600405347, 'leaf_weight': 514.2693380862474, 'leaf_count': 5806}
{'leaf_index': 18, 'leaf_value': -3.01381609888255, 'leaf_weight': 221.04787051677704, 'leaf_count': 4614}
{'leaf_index': 1, 'leaf_value': -3.0336576123606727, 'leaf_weight': 2667.005198687315, 'leaf_count': 56171}
{'leaf_index': 6, 'leaf_value': -1.0930359013819269, 'leaf_weight': 630.5078001469374, 'leaf_count': 1677}
{'leaf_index': 3, 'leaf_value': -2.6955877051335113, 'leaf_weight': 83.39051477611065, 'leaf_count': 1489}
{'leaf_index': 12, 'leaf_value': -0.9320870000416277, 'leaf_weight': 47102.81295746565, 'leaf_count': 53395}
{'leaf_index': 9, 'leaf_value': -2.339730727422376, 'leaf_weight': 188.79415191709995, 'leaf_count': 2734}
{'leaf_index': 8, 'leaf_value': -2.903086908469149, 'leaf_weight': 201.27797167003155, 'leaf_count': 3990}

tree_index: 1
{'leaf_index': 0, 'leaf_value': 1.7003719046589805, 'leaf_weight': 89.89699831604958, 'leaf_count': 526}
{'leaf_index': 6, 'leaf_value': -0.008478093867401493, 'leaf_weight': 606.4826318323612, 'leaf_count': 12085}
{'leaf_index': 18, 'leaf_value': 0.35854053128585933, 'leaf_weight': 21147.70379064977, 'leaf_count': 7521}
{'leaf_index': 16, 'leaf_value': 1.7996142884045683, 'leaf_weight': 101.33498433232307, 'leaf_count': 316}
{'leaf_index': 19, 'leaf_value': 0.6181301642947885, 'leaf_weight': 85.0488400682807, 'leaf_count': 1175}
{'leaf_index': 17, 'leaf_value': 0.2108335293509681, 'leaf_weight': 161.64981354773045, 'leaf_count': 331}
{'leaf_index': 15, 'leaf_value': -0.016521274681180857, 'leaf_weight': 423.0099447518587, 'leaf_count': 7536}
{'leaf_index': 4, 'leaf_value': -0.06392728087564778, 'leaf_weight': 1595.620696157217, 'leaf_count': 32539}
{'leaf_index': 2, 'leaf_value': -0.08846515759106144, 'leaf_weight': 41799.491890221834, 'leaf_count': 953595}
{'leaf_index': 12, 'leaf_value': 0.3285022589016781, 'leaf_weight': 520.416460648179, 'leaf_count': 1191}
{'leaf_index': 9, 'leaf_value': -0.013072092095162056, 'leaf_weight': 1560.870567932725, 'leaf_count': 26635}
{'leaf_index': 14, 'leaf_value': 0.29746060409739705, 'leaf_weight': 973.760700315237, 'leaf_count': 12824}
{'leaf_index': 11, 'leaf_value': 1.2303136226518105, 'leaf_weight': 78.05999701470137, 'leaf_count': 449}
{'leaf_index': 8, 'leaf_value': 1.5758433007286676, 'leaf_weight': 44.83048837631941, 'leaf_count': 315}
{'leaf_index': 7, 'leaf_value': -0.10539180772863799, 'leaf_weight': 805.8025468811393, 'leaf_count': 16600}
{'leaf_index': 13, 'leaf_value': 0.26696944007068507, 'leaf_weight': 1808.0697652101517, 'leaf_count': 17543}
{'leaf_index': 5, 'leaf_value': 0.29779065829637386, 'leaf_weight': 1361.8919109031558, 'leaf_count': 10420}
{'leaf_index': 1, 'leaf_value': -0.017633350811942006, 'leaf_weight': 852.0203822031617, 'leaf_count': 17298}
{'leaf_index': 10, 'leaf_value': 0.3528788566582046, 'leaf_weight': 207151.9944522865, 'leaf_count': 64972}
{'leaf_index': 3, 'leaf_value': -0.07833613971012304, 'leaf_weight': 1702.7047363184392, 'leaf_count': 37186}

How can I interpret these values as belonging to 0 or 1 classes?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP