Created
December 12, 2020 11:41
-
-
Save dan0nchik/6b8294946efba91632fb04ec0fdab0b7 to your computer and use it in GitHub Desktop.
Script for showing optimal features for classifying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.ensemble import ExtraTreesClassifier | |
import matplotlib.pyplot as plt | |
model = ExtraTreesClassifier() | |
model.fit(X,y) | |
f = plt.figure(figsize=(10, 10)) | |
print(model.feature_importances_) #use inbuilt class feature_importances of tree based classifiers | |
#plot graph of feature importances for better visualization | |
feat_importances = pd.Series(model.feature_importances_, index=X.columns) | |
feat_importances.nlargest(30).plot(kind='barh') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment