Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #random forest feature importance
- import matplotlib.pyplot as plt
- for f in range(x_train.shape[1]):
- print("%d. feature %d (%f)" % (f + 1, indices[f], importances[indices[f]]))
- # Plot the feature importances of the forest
- plt.figure(1, figsize=(14, 13))
- plt.title("Feature importances")
- plt.bar(range(x_train.shape[1]), importances[indices], color="g", yerr=std[indices], align="center")
- plt.xticks(range(x_train.shape[1]), x_train.columns[indices],rotation=90)
- plt.xlim([-1, x_train.shape[1]])
- plt.show()
Add Comment
Please, Sign In to add comment