Skip to content

Instantly share code, notes, and snippets.

@marcusrehm
Created July 3, 2018 18:15
Show Gist options
  • Save marcusrehm/e1124d93d3d3e3a7bee4df106d527302 to your computer and use it in GitHub Desktop.
Save marcusrehm/e1124d93d3d3e3a7bee4df106d527302 to your computer and use it in GitHub Desktop.
View model importance in Spark
print('Feature Importance:')
featureImportances = model.stages[7].featureImportances
for keyPair in spark.sparkContext \
.parallelize(zip(features,
featureImportances.toArray())) \
.sortBy(lambda pair: -pair[1]) \
.collect():
print('{0}: {1}'.format(keyPair[0], keyPair[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment