[MRG+1] change module from pydotplus to graphviz
[MRG+2] change module from pydotplus to graphviz
@@ -126,41 +126,35 @@ Using the Iris dataset, we can construct a tree as follows::
Once trained, we can export the tree in `Graphviz
<http://www.graphviz.org/>`_ format using the :func:`export_graphviz`
-exporter. Below is an example export of a tree trained on the entire
-iris dataset::
+exporter. If you use the `conda <http://conda.io>`_ package manager, the graphviz binaries
+and the python package can be installed with
- >>> with open("iris.dot", 'w') as f:
- ... f = tree.export_graphviz(clf, out_file=f)
+ conda install python-graphviz
-Then we can use Graphviz's ``dot`` tool to create a PDF file (or any other
-supported file type): ``dot -Tpdf iris.dot -o iris.pdf``.
+Alternatively binaries for graphviz can be downloaded from the graphviz project homepage,
+and the Python wrapper installed from pypi with `pip install graphviz`.
-::
+Below is an example graphviz export of the above tree trained on the entire
+iris dataset; the results are saved in an output file `iris.pdf`::
- >>> import os
- >>> os.unlink('iris.dot')
-Alternatively, if we have Python module ``pydotplus`` installed, we can generate
-a PDF file (or any other supported file type) directly in Python::
-
- >>> import pydotplus # doctest: +SKIP
+ >>> import graphviz # doctest: +SKIP
>>> dot_data = tree.export_graphviz(clf, out_file=None) # doctest: +SKIP
- >>> graph = pydotplus.graph_from_dot_data(dot_data) # doctest: +SKIP
- >>> graph.write_pdf("iris.pdf") # doctest: +SKIP
+ >>> graph = graphviz.Source(dot_data) # doctest: +SKIP
+ >>> graph.render("iris") # doctest: +SKIP
The :func:`export_graphviz` exporter also supports a variety of aesthetic
options, including coloring nodes by their class (or value for regression) and
-using explicit variable and class names if desired. IPython notebooks can also
-render these plots inline using the `Image()` function::
+using explicit variable and class names if desired. Jupyter notebooks also
+render these plots inline automatically::
- >>> from IPython.display import Image # doctest: +SKIP
>>> dot_data = tree.export_graphviz(clf, out_file=None, # doctest: +SKIP
feature_names=iris.feature_names, # doctest: +SKIP
class_names=iris.target_names, # doctest: +SKIP
filled=True, rounded=True, # doctest: +SKIP
special_characters=True) # doctest: +SKIP
- >>> graph = pydotplus.graph_from_dot_data(dot_data) # doctest: +SKIP
- >>> Image(graph.create_png()) # doctest: +SKIP
+ >>> graph = graphviz.Source(dot_data) # doctest: +SKIP
+ >>> graph # doctest: +SKIP
.. only:: html
