Skip to content

Instantly share code, notes, and snippets.

@ImadDabbura
Created August 3, 2018 20:59
Show Gist options
  • Select an option

  • Save ImadDabbura/666662672683733882356fe91b2b31e8 to your computer and use it in GitHub Desktop.

Select an option

Save ImadDabbura/666662672683733882356fe91b2b31e8 to your computer and use it in GitHub Desktop.
# fit RF to plot feature importances
rf_clf.fit(RobustScaler().fit_transform(
Imputer(strategy="median").fit_transform(X_train)), y_train)
# Plot features importance
importances = rf_clf.feature_importances_
indices = np.argsort(rf_clf.feature_importances_)[::-1]
plt.figure(figsize=(12, 6))
plt.bar(range(1, 25), importances[indices], align="center")
plt.xticks(range(1, 25),
df.columns[df.columns != "not_fully_paid"][indices],
rotation=90)
plt.title("Feature Importance", {"fontsize": 16});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment