How to display high resolution picture of the decision tree in Python?

Viewed 2639

Am using the following code to extract rules. Please help me plot a tree of higher resolution as the image gets blurred when I increase the tree depth.

from sklearn.tree import DecisionTreeClassifier
from sklearn import tree
classifier = DecisionTreeClassifier(max_depth = 3,random_state = 0)
tree.plot_tree(classifier);

Also, how can I extract rule from a random Forest Classifier.

Also are there

1 Answers

I'd just save the plot to a PDF file and use that to zoom in to whichever part you want

just put plt.savefig('out.pdf') after your call to plot_tree and matplotlib should do the right thing

note that any "vector" image format will do the right thing here, so a svg file would also be a fine choice as image editors tend to support zooming more nicelyer

Related