Skip to content

Instantly share code, notes, and snippets.

@seahrh
Created November 6, 2020 09:41
Show Gist options
  • Save seahrh/c5a5e841340f5f805fe2b86bfbb326e9 to your computer and use it in GitHub Desktop.
Save seahrh/c5a5e841340f5f805fe2b86bfbb326e9 to your computer and use it in GitHub Desktop.
Put feature importance scores in dataframe
feature_important = clf.get_booster().get_score(importance_type="weight")
keys = list(feature_important.keys())
values = list(feature_important.values())
data = pd.DataFrame(data=values, index=keys, columns=["score"]).sort_values(by = "score", ascending=False)
# Top 10 features
data.head(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment