I am actively learning how to implement decision trees in python.
When recreating the Iris classification example from scikit-learn, i get a TypeError for parameters that exist in export_graphviz, namely 'class_names' and 'plot_options'.
from IPython.display import Image
import sklearn
dot_data = StringIO()
sklearn.tree.export_graphviz(clf, out_file=dot_data,
plot_options=['class', 'filled', 'label', 'sample', 'proportion'],
target_names=iris['target_names'],
feature_names=iris['feature_names'])
graph = pydot.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())
The error for the specific code above is:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-33-aba117838252> in <module>()
5 plot_options=['class', 'filled', 'label', 'sample', 'proportion'],
6 target_names=iris['target_names'],
----> 7 feature_names=iris['feature_names'])
8 graph = pydot.graph_from_dot_data(dot_data.getvalue())
9 Image(graph.create_png())
TypeError: export_graphviz() got an unexpected keyword argument 'plot_options'
On my computer, I have graphviz and pydot2 installed. I receive an error when trying to install pygraphviz:
If you think your installation is correct you will need to manually
change the include_dirs and library_dirs variables in setup.py to
point to the correct locations of your graphviz installation.
The current setting of library_dirs and include_dirs is:
library_dirs=None
include_dirs=None
error: Error locating graphviz.
Is there a work around/solution to allow me to use the parameters in export_graphviz in order to build the tree visualization I want? Would pursuing a solution to the pygraphviz install error lead to a solution for my tree?
Thank you,
plot_options,target_names, etc in the following example? And what do you want to visualise exactly?