您的位置:首页 > 编程语言 > Python开发

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

2016-12-15 12:22 2927 查看
xgboost

代码

# plot decision tree
from numpy import loadtxt
from xgboost import XGBClassifier
from xgboost import plot_tree
import matplotlib.pyplot as plt
from graphviz import Digraph
# load data
import pydot

# print pydot.find_graphviz()

dataset = loadtxt('pima-indians-diabetes.csv', delimiter=",")
# split data into X and y
X = dataset[:, 0:8]
y = dataset[:, 8]
# fit model no training data
model = XGBClassifier()
model.fit(X, y)
# plot single tree
plot_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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐