本文介绍了在AWS Sagemaker上安装graphiz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用Python3的Jupyter笔记本上,并尝试使用以下代码绘制树:
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)
在最后一行,我得到:
~/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
如何安装graphviz,以便可以看到plot_tree?
How do I install graphviz so I can see the plot_tree?
推荐答案
我终于知道Conda有一个可以为您安装的软件包.我可以通过运行以下命令来安装它:
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
请注意,只有在安装需要验证添加/更改其他软件包的情况下才需要--yes
,因为Jupyter笔记本计算机一旦运行便无法交互.
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.
这篇关于在AWS Sagemaker上安装graphiz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!