扩展DecisionTreeRegressionModel的模型使用featureImportances
方法。如果使用Pipelines构建模型,则会有Model[_]
类型的对象。
对于那些支持该方法的模型,如何从这些管道中获取featureImportances
?
答案 0 :(得分:0)
如果您知道决策树所在的管道的哪个阶段很容易。例如,如果决策树处于第三阶段,您可以执行以下操作:
val featureImportances = pipelineModel
.stages(2) // The position in the pipeline of the stage you want
.asInstanceOf[DecisionTreeRegressionModel]
.featureImportances