I want to plot the decision tree of XGBoost. I followed the instructions from this webpage. I get this error:
ImportError: You must install graphviz to plot tree
I tried to install graphviz_2.38.0-1~saucy_amd64.deb from graphviz. But I get this error:
*Dependency is not satisfiable:libgraphviz4(>=2.18)*
So I did what is on this link
As it still does not work I downloaded the source code: graphviz-2.40.1.tar.gz But it still does not work. I thought that maybe I have installed it in the wrong path. So what does this mean: Make sure that the directory containing the dot executable is on your systems’ path?
I have installed it in /etc.
I use a virtual environment in conda
Any suggestions on what am I doing wrong?
EDIT:
I used pip install graphviz. now I get this error:
CalledProcessError: Command '['dot', '-Tpng']' returned non-zero exit status 1
Any idea?
The scikit-learn (sklearn) library added a new function that allows us to plot the decision tree without GraphViz. So we can use the plot_tree function with the matplotlib library. If you are new to Python, Just into Data is now offering a FREE Python crash course: breaking into data science!
Graphviz is a standard package on many linux distributions. You can check if it is installed with a command like dpkg -s graphivz . If it is not installed, you should be able to install it with your system's package manager. i.e. sudo apt-get install graphviz or search 'graphivz' in the Software Center on Ubuntu.
As per this answer, you will need to install two conda packages:
So, install both packages with
conda install graphviz python-graphviz
and you should be ready to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With