Graphviz.Source not showing up in Jupyter Notebook

After exporting a .dot file using scikit-learn, a convenient function export_graphviz.

I am trying to display a points file using Graphviz in the cell of my Jupyter laptop:

import graphviz
from IPython.display import display

with open("tree_1.dot") as f:
    dot_graph = f.read()
display(graphviz.Source(dot_graph))

However, out [] is just an empty cell.

I use graphviz 0.5(pip, then conda is installed), iPython 5.1and Python 3.5. The file point looks correct, here are the first characters:

digraph Tree {\nnode [shape=box, style="filled", color=

iPython display seems to work for other objects, including Matplotlib graphics and Pandas data frames.

It is worth noting that the example on the Graphviz website also does not work.

+7
source share
4

, , , , , .

, :

Python 2.7.10

IPython 5.1.0

graphviz 0.7.1

.dot , jupyter out [.] :

import graphviz

with open("tree_1.dot") as f:
    dot_graph = f.read()

# remove the display(...)

graphviz.Source(dot_graph)
+5
graphviz.Source(dot_graph).view()
+2

pydotplus.

import pydotplus

by (1.1) .dot

pydot_graph = pydotplus.graph_from_dot_file("clf.dot")

(1.2) .export_graphviz

dt = tree.DecisionTreeClassifier()
dt = clf.fit(x,y)
dt_graphviz = tree.export_graphviz(dt, out_file = None)

pydot_graph = pydotplus.graph_from_dot_data(dt_graphviz)

(2.), pyplot

from IPython.display import Image

Image(pydot_graph.create_png())
+1

conda remove graphviz
conda install python-graphviz
graphviz.Source(dot_graph).view()
0

Source: https://habr.com/ru/post/1659125/


All Articles