Scala 从Spark'中寻找重要性值;基于MLlib的决策树
我们正在使用MLlib为决策树运行Spark 1.0或1.1 当我使用示例数据运行示例SCALA代码时,它没有错误,但我无法从结果中找到特性的重要性Scala 从Spark'中寻找重要性值;基于MLlib的决策树,scala,apache-spark,decision-tree,apache-spark-mllib,Scala,Apache Spark,Decision Tree,Apache Spark Mllib,我们正在使用MLlib为决策树运行Spark 1.0或1.1 当我使用示例数据运行示例SCALA代码时,它没有错误,但我无法从结果中找到特性的重要性 有人知道如何获取这些值吗?当你在最后训练DecisionTreeModel时,你就有了这门课 class DecisionTreeModel(val topNode: Node, val algo: Algo) { ... } 您可以从顶部开始遍历节点,并从中获得所需的所有内容(predict+InformationGainStats) 当
有人知道如何获取这些值吗?当你在最后训练DecisionTreeModel时,你就有了这门课
class DecisionTreeModel(val topNode: Node, val algo: Algo) {
...
}
您可以从顶部开始遍历节点,并从中获得所需的所有内容(predict+InformationGainStats)
当你在最后训练DecisionTreeModel时,你就有了这个类
class DecisionTreeModel(val topNode: Node, val algo: Algo) {
...
}
您可以从顶部开始遍历节点,并从中获得所需的所有内容(predict+InformationGainStats)
在Spark 2+中,您可以执行以下操作:
val vectorAssembler = new VectorAssembler().setInputCols(featureArray)
val decisionTreeModel = decisionTree.fit(trainingDataset)
val featureImportances = decisionTreeModel.featureImportances // Sparse or Dense Vector
featureArray.zip(featureImportances.toArray).sortBy(_._2).reverse
在Spark 2+中,您可以执行以下操作:
val vectorAssembler = new VectorAssembler().setInputCols(featureArray)
val decisionTreeModel = decisionTree.fit(trainingDataset)
val featureImportances = decisionTreeModel.featureImportances // Sparse or Dense Vector
featureArray.zip(featureImportances.toArray).sortBy(_._2).reverse
请发布您尝试的内容和结果。我们不是心灵感应。请发布您尝试过的内容和结果。我们没有心灵感应。