Skip to content

Instantly share code, notes, and snippets.

@GINK03
Created August 2, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GINK03/25015b6421d45296f9038050151647bc to your computer and use it in GitHub Desktop.
Save GINK03/25015b6421d45296f9038050151647bc to your computer and use it in GitHub Desktop.
lightgbm-gain
def __getImp__(model):
    split = dict(zip(model.feature_name(), model.feature_importance('split')))
    split = pd.DataFrame.from_dict(split, orient='index')
    split.columns = ['split']
    
    gain = dict(zip(model.feature_name(), model.feature_importance('gain')))
    gain = pd.DataFrame.from_dict(gain, orient='index')
    gain.columns = ['gain']
    
    return pd.concat([split, gain], axis=1)
    
# modei is booster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment