Skip to content

Instantly share code, notes, and snippets.

@notha99y
Created December 19, 2018 08:59
Show Gist options
  • Save notha99y/477ba6dd54a5979f68fed71be708cae6 to your computer and use it in GitHub Desktop.
Save notha99y/477ba6dd54a5979f68fed71be708cae6 to your computer and use it in GitHub Desktop.
from sklearn.ensemble import RandomForestClassifier
rf_clf = RandomForestClassifier(n_estimators = 500, max_depth=12)
rf_clf.fit(X_train, y_train)
rf_y_pred = rf_clf.predict(X_val)
pd.Series(rf_clf.feature_importances_, index = X_train.columns).nlargest(12).plot(kind = 'barh',
figsize = (10, 10),
title = 'Feature importance from RandomForest').invert_yaxis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment