-
-
Save sazio/f94bc851d9e8b78c2975215f94955505 to your computer and use it in GitHub Desktop.
This file contains 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
# xgboost for feature importance on a classification problem | |
from xgboost import XGBClassifier | |
from matplotlib import pyplot | |
# define the model | |
model = XGBClassifier() | |
# fit the model | |
model.fit(X_clf, y_clf) | |
# get importance | |
importance = model.feature_importances_ | |
# summarize feature importance | |
for i,v in enumerate(importance): | |
print('Feature: %0d, Score: %.5f' % (i,v)) | |
# plot feature importance | |
pyplot.bar([x for x in range(len(importance))], importance) | |
pyplot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment