在AWS Sagemaker上安装graphviz

问题描述 投票:0回答:1

我正在使用Python3的Jupyter笔记本上,并试图用这样的代码绘制树:

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?

xgboost amazon-sagemaker
1个回答
0
投票

我终于得知康达有一个可以为你安装它的软件包。我可以通过运行命令来安装它:

!conda install python-graphviz --yes

请注意,只有在安装需要验证添加/更改其他软件包时才需要--yes,因为Jupyter笔记本在运行后不是交互式的。

© www.soinside.com 2019 - 2024. All rights reserved.