【发布时间】:2023-04-05 04:51:01
【问题描述】:
我在使用 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?
【问题讨论】: