Created
October 3, 2018 09:46
-
-
Save vikramsoni2/ae0b8888400320ebb20939123ce690a3 to your computer and use it in GitHub Desktop.
LGBMClassifier feature ranking
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
imp = pd.DataFrame({'feats':predictors, | |
'ranks': clf.feature_importances_}).sort_values('ranks', ascending=False) | |
fig, ax = plt.subplots(figsize=(12, 15)) | |
# Example data | |
features = np.arange(len(imp.feats)) | |
ranking = imp.ranks | |
ax.barh(features, ranking, align='center', color='skyblue', ecolor='black') | |
ax.set_yticks(features) | |
ax.set_yticklabels(imp.feats) | |
ax.invert_yaxis() # labels read top-to-bottom | |
ax.set_xlabel('Ranking') | |
ax.set_title('Featre importance') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment