How to view Random Forest statistics in Spark (scala)

前端 未结 1 1208
北海茫月
北海茫月 2021-01-25 21:46

I have a RandomForestClassifierModel in Spark. Using .toDebugString() outputs the following

Tree 0 (weight 1.0):
  If (feature 0 in {1.0,2.0,3.0})
   If (feature         


        
相关标签:
1条回答
  • 2021-01-25 22:41

    One way I found useful yesterday was I could use spark.read.parquet() function to read the output from the model/data file. This way all information about a certain node could be retrieved as a whole dataframe.

    `val modelPath = "some/path/to/your/model"
    val dataPath = modelPath + "/data"    
    val nodeData: DataFrame = spark.read.parquet(dataPath)
    nodeData.show(500,false)
    nodeData.printSchema()`
    

    Then you can rebuild the tree with information. Hope it helps.

    0 讨论(0)
提交回复
热议问题