PySpark & MLLib: Random Forest Feature Importances

前端 未结 4 1925
情书的邮戳
情书的邮戳 2020-12-08 22:27

I\'m trying to extract the feature importances of a random forest object I have trained using PySpark. However, I do not see an example of doing this anywhere in the documen

4条回答
  •  一个人的身影
    2020-12-08 22:50

    I believe that this now works. You can call:

    from pyspark.ml.classification import RandomForestClassifier
    rf = RandomForestClassifier()
    model = rf.fit(data)
    print model.featureImportances
    

    Running fit on a RandomForestClassifier returns a RandomForestClassificationModel which has the desired featureImportances calculated. I hope that this helps : )

提交回复
热议问题