After training a Random Forest classifier with Spark MLlib, which attribute provides feature importance scores?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Spark MLlib's tree ensemble models expose importance scores through the featureImportances attribute — note the camelCase, which is Spark's Java-heritage convention, not scikit-learn's underscore style.
Full explanation below image
Full Explanation
In Spark MLlib, RandomForestClassificationModel and RandomForestRegressionModel (and GBTClassificationModel, GBTRegressionModel) expose feature importance scores via the model.featureImportances attribute, which returns a SparseVector of importance scores indexed by feature position. Important notes: 1) These are impurity-based importances by default (similar to scikit-learn's 'gini importance'). 2) The indices correspond to the VectorAssembler input column order. 3) To map scores back to feature names, you need to zip with the VectorAssembler's inputCols list. model.coefficients is a Linear Models attribute (LogisticRegression, LinearRegression). model.feature_importances_ uses scikit-learn's underscore convention — Spark uses camelCase. model.featureWeights is not a valid attribute in Spark MLlib.