Skip to content

Instantly share code, notes, and snippets.

@bfraiche
Last active April 2, 2019 22:17
Show Gist options
  • Save bfraiche/b7745787cad3a54cb6018d9769517378 to your computer and use it in GitHub Desktop.
Save bfraiche/b7745787cad3a54cb6018d9769517378 to your computer and use it in GitHub Desktop.
This gist contains code snippets for my blogpost: 'Random Forest with Python and Spark ML'
bestPipeline = cvModel.bestModel
bestModel = bestPipeline.stages[1]
importances = bestModel.featureImportances
x_values = list(range(len(importances)))
plt.bar(x_values, importances, orientation = 'vertical')
plt.xticks(x_values, feature_list, rotation=40)
plt.ylabel('Importance')
plt.xlabel('Feature')
plt.title('Feature Importances')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment