问题
As the question says, is there any equivalent of Spark org.apache.spark.mllib.tree.model.DecisionTreeClassificationModel.toDebugString()
in org.apache.spark.ml.classification.DecisionTreeClassificationModel
I have gone through the API doc of the latter and found this method rootNode()
which gives back a org.apache.spark.ml.tree.Node
object which seems to be a recursive object, so should I use this class instead to build the tree structure myself?
Thanks in anticipation.
回答1:
org.apache.spark.ml.classification.DecisionTreeClassificationModel already have a toDebugString() method implemented because it has DecisionTreeModel as a trait.
Example:
class org.apache.spark.ml.classification.DecisionTreeClassificationModel
DecisionTreeClassificationModel of depth 1 with 3 nodes
If (feature 378 <= 71.0)
Predict: 1.0
Else (feature 378 > 71.0)
Predict: 0.0
来源:https://stackoverflow.com/questions/37678365/equivalent-of-mllib-decisiontreemodel-todebugstring-in-ml-decisiontreeclassifi