python-Xgboost可视化问题 You must install graphviz to plot tree

来源:互联网 发布:淘宝商家营销手段 编辑:程序博客网 时间:2024/06/08 11:14

xgboost

代码

# plot decision treefrom numpy import loadtxtfrom xgboost import XGBClassifierfrom xgboost import plot_treeimport matplotlib.pyplot as pltfrom graphviz import Digraph# load dataimport pydot# print pydot.find_graphviz()dataset = loadtxt('pima-indians-diabetes.csv', delimiter=",")# split data into X and yX = dataset[:, 0:8]y = dataset[:, 8]# fit model no training datamodel = XGBClassifier()model.fit(X, y)# plot single treeplot_tree(model)plt.show()

遇到问题
You must install graphviz to plot tree

解决办法
1. https://pypi.python.org/pypi/graphviz/0.3.3
2. pip install graphviz

Here is the web page of that graphviz. This is a python package called
graphviz. Bad choice of name. You need to install the c version of
graphvis. See this web page:

https://pypi.python.org/pypi/graphviz/0.3.3

From the command line, the command “dot” should work. Look into you OS to
know if it provide graphviz. If so, it will be probably the c version.

Fred

参考资料:
- https://github.com/Theano/Theano/issues/1801

0 0
原创粉丝点击