2
$\begingroup$

In Jupyter displaying the DT is done as follows:

# Display in jupyter notebook
from IPython.display import Image
Image(filename = 'tree.png')

How to see DT in anaconda?

$\endgroup$
0
$\begingroup$

there is a simpler way but sometimes it doesn't work first, you should call your method like this

tree_clf=tree.DecisionTree()

then you can choose a name and path for it, let others remain the same as I did so overall, it would look like:

from sklearn.tree import export_graphviz
export_graphviz(
tree_clf,
out_file=image_path("iris_tree.dot"),
feature_names=iris.feature_names[2:],
class_names=iris.target_names,
rounded=True,
filled=True
)

hope it works for you

| improve this answer | |
$\endgroup$
  • $\begingroup$ Welcome to DS StackExchange. Could you please elaborate more on your explanation? $\endgroup$ – Leevo Jan 9 at 10:40
  • $\begingroup$ thanks, sry I thought it was enough of explanation $\endgroup$ – parsa Jan 9 at 12:32
0
$\begingroup$

Below is my code for visualizing a decision tree. Hope it helps.

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.