Decision Tree Visualization with pydotplus


A useful snippet for visualizing decision trees with pydotplus. It took some digging to find the proper output and viz parameters among different documentation releases, so thought I’d share it here for quick reference.

The tree here looks at sample characteristics of hired and non-hired job applicants.

from sklearn import tree
from IPython.display import Image
import pydotplus
dt = tree.DecisionTreeClassifier(random_state=3, criterion='entropy',
splitter='best', max_depth=None, min_samples_split=1)

clf =, Y)
dot_data = tree.export_graphviz(clf, out_file="",
filled=True, rounded=True, special_characters=True, leaves_parallel=False)

graph = pydotplus.graphviz.graph_from_dot_file("")


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: