2014-12-04 2 views
0

MLlib를 사용하여 의사 결정 트리에 대해 Spark 1.0 또는 1.1을 실행하고 있습니다.MLlib를 사용하여 Spark의 의사 결정 트리에서 중요도 찾기

샘플 데이터로 샘플 SCALA 코드를 실행할 때 오류없이 작동했지만 결과에서 기능 중요성을 찾지 못했습니다.

아무도 값을 가져 오는 방법에 대한 정보가 있습니까? 당신이 마지막에 DecisionTreeModel을 훈련 할 때

+1

시도한 내용과 결과를 게시하십시오. 우리는 텔레파시가 아닙니다. –

답변

1

당신은 당신은 정상에서 노드를 통과 시작할 수 있습니다, 당신은

class Node (
    val id: Int, 
    val predict: Double, 
    val isLeaf: Boolean, 
    val split: Option[Split], 
    var leftNode: Option[Node], 
    var rightNode: Option[Node], 
    val stats: Option[InformationGainStats]) 
2
(+ InformationGainStats을 예측) 당신이 그것에서 필요로하는 모든를 얻을 수 있습니다,이 클래스를

class DecisionTreeModel(val topNode: Node, val algo: Algo) { 
    ... 
} 

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 
관련 문제