x,y = datasets.make_classification(1000,20,n_informative = 3)from sklearn.tree import DecisionTreeClassifierdt = DecisionTreeClassifier()dt.fit(x,y)from sklearn import datasets
from StringIO import StringIO from sklearn import tree import pydot str_buffer = StringIO() tree.export_graphviz(dt,out_file = str_buffer) graph = pydot.graph_from_dot_data(str_buffer.getvalue()) graph.write("myfile.jpg")
输出错误:“AttributeError: 'list' object has no attribute 'write_pdf'”。
查了一下,是缺少Graphviz。按照下面的方式安装了Graphviz和pygraphviz。</
AttributeError: 'list' object has no attribute 'write_pdf'
最新推荐文章于 2024-05-31 17:16:31 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)