Install graphiz on AWS Sagemaker

倾然丶 夕夏残阳落幕 提交于 2019-12-02 17:59:47

问题


I'm on a Jupyter notebook using Python3 and trying to plot a tree with code like this:

import xgboost as xgb
from xgboost import plot_tree

plot_tree(model, num_trees=4)

On the last line I get:

~/anaconda3/envs/python3/lib/python3.6/site-packages/xgboost/plotting.py in to_graphviz(booster, fmap, num_trees, rankdir, yes_color, no_color, **kwargs)
196         from graphviz import Digraph
197     except ImportError:
--> 198         raise ImportError('You must install graphviz to plot tree')
199 
200     if not isinstance(booster, (Booster, XGBModel)):

ImportError: You must install graphviz to plot tree

How do I install graphviz so I can see the plot_tree?


回答1:


I was finally able to learn that Conda has a package which can install it for you. I was able to get it installed by running the command:

!conda install python-graphviz --yes

Note the --yes is only needed if the installation needs to verify adding/changing other packages since the Jupyter notebook is not interactive once it is running.



来源:https://stackoverflow.com/questions/55112494/install-graphiz-on-aws-sagemaker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!