Skip to content

Instantly share code, notes, and snippets.

@danyashorokh
Last active October 5, 2017 08:56
Show Gist options
  • Save danyashorokh/563ea8b5b617ce9157ce563641d95c2b to your computer and use it in GitHub Desktop.
Save danyashorokh/563ea8b5b617ce9157ce563641d95c2b to your computer and use it in GitHub Desktop.
[Python] Important model features
clf = ensemble.GradientBoostingClassifier(**BOOSTING_PARAMS)
clf.fit(X_train, y_train)
predictors = [x for x in df_fin.columns if x not in ['ID1', 'ID2']]
feat_imp = pd.Series(clf.feature_importances_, index=predictors).sort_values(ascending=False)
# print(feat_imp.axes, feat_imp.values)
with open('path', 'a') as f:
for el in feat_imp.iteritems():
f.write(str(el)+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment