I am using pyspark through Jupyterlab to build decision tree using following code:
from pyspark.ml.classification import DecisionTreeClassifier
# train our model using training data
dt = DecisionTreeClassifier(labelCol="labelIndex", featuresCol="features")
model = dt.fit(training)
when i do print(model.toDebugString) then i get decision tree as :
DecisionTreeClassificationModel: uid=DecisionTreeClassifier_b62e15bb102c, depth=5, numNodes=11, numClasses=2, numFeatures=6
If (feature 3 <= 5.5)
Predict: 0.0
Else (feature 3 > 5.5)
If (feature 1 <= 8.5)
If (feature 5 <= 0.5)
Predict: 0.0
Else (feature 5 > 0.5)
If (feature 3 <= 23.5)
Predict: 0.0
Else (feature 3 > 23.5)
If (feature 5 <= 11.5)
Predict: 1.0
Else (feature 5 > 11.5)
Predict: 0.0
Else (feature 1 > 8.5)
Predict: 0.0
But i want to Visualize this to rule set into decision tree diagram ? Anyone knows how to do that ?