Drawing Decision tree with python

Question:

I working on a draw decision tree with python,

tree.plot_tree(clf.fit(X_train, y_train))
plt.suptitle("Decision surface of a decision tree using paired features")
plt.show()

but when I run this code, the tree shows up like this

Decision Tree

Is there any possible way to make the tree normal?

Asked By: jkim37

||

Answers:

export_graphviz might be a good alternative for you.

Here is a Kaggle notebook that explains how to make the best use of this functionality provided by sklearn.

For the plot_tree function you are using you can try changing the font size using the fontsize argument. Or you can also try changing the size of the figure if you haven’t already done that by doing something like this –

fig = matplotlib.pyplot.gcf()
fig.set_size_inches(x, y) #dimensions you want
Answered By: Samarth