I am using Apache Spark Mllib 1.4.1 (PySpark, the python implementation of Spark) to generate a decision tree based on LabeledPoint data I have. The tree generates correctly and I can print it to the terminal (extract the rules as this user calls it How to extract rules from decision tree spark MLlib) using:
model = DecisionTree.trainClassifier( ... )
print(model.toDebugString()
But what I want to do is visualize or plot the decision tree rather than printing it to the terminal. Is there any way I can plot the decision tree in PySpark or maybe I can save the decision tree data and use R to plot it? Thanks!
There is this project Decision-Tree-Visualization-Spark for visualizing decision tree model
It has two steps
For the parser check Dt.py
The input to the function def tree_json(tree)
is your models toDebugString()
Answer from question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With