Skip to content

Commit 8b6a226

Browse files
authored
Create XGB Feature Importance
1 parent 9f5b645 commit 8b6a226

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

XGB Feature Importance

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def importance_XGB(model):
2+
impdf = []
3+
for ft, score in model.get_fscore().iteritems():
4+
impdf.append({'feature': ft, 'importance': score})
5+
impdf = pd.DataFrame(impdf)
6+
impdf = impdf.sort_values(by='importance', ascending=False).reset_index(drop=True)
7+
impdf['importance'] /= impdf['importance'].sum()
8+
return impdf
9+
10+
importance_XGB(model)

0 commit comments

Comments
 (0)