Created
July 3, 2018 18:15
-
-
Save marcusrehm/e1124d93d3d3e3a7bee4df106d527302 to your computer and use it in GitHub Desktop.
View model importance in Spark
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
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