AttributeError: 'list' object has no attribute 'write_pdf'
来源:互联网 发布:eclipse python import 编辑:程序博客网 时间:2024/06/05 10:13
AttributeError: 'list' object has no attribute 'write_pdf'
我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf'
我使用的是python3.4
1
2
3
4
5
6
from
sklearn.externals.six
import
StringIO
import
pydot
dot_data
=
StringIO()
tree.export_graphviz(clf, out_file
=
dot_data)
graph
=
pydot.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf(
"iris.pdf"
)
查阅资料后发现,原来我使用的是较新版本的python.可以采取如下两种解决方案:
try with pydotplus:
1
2
3
4
import
pydotplus
...
graph
=
pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf(
"iris.pdf"
)
pydot.graph_from_dot_data()
returns a list, so try:
1
2
graph
=
pydot.graph_from_dot_data(dot_data.getvalue())
graph[
0
].write_pdf(
"iris.pdf"
)
阅读全文
0 0
- AttributeError: 'list' object has no attribute 'write_pdf'
- AttributeError: 'list' object has no attribute 'write_pdf'
- sqlalchemy enum AttributeError: 'list' object has no attribute 'replace'
- scrapy出现:AttributeError: 'list' object has no attribute 'xpath'
- AttributeError: 'classmethod' object has no attribute '__module__'
- AttributeError: 'module' object has no attribute 'getpass'
- AttributeError: ‘NoneType’ object has no attribute ‘clone’
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'NoneType' object has no attribute 'clone'
- AttributeError: 'tuple' object has no attribute 'Multi'
- AttributeError: 'Response' object has no attribute 'json'
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'Connection' object has no attribute 'connection_errors'
- AttributeError: 'module' object has no attribute 'randint'
- AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
- AttributeError: 'WebDriver' object has no attribute
- AttributeError: 'NoneType' object has no attribute
- AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'
- 3.UE4的程序控制
- PrintWriter类和PrintStream类的学习总结
- java反射机制
- Android开源库
- Mybatis入门(基于MySQL)
- AttributeError: 'list' object has no attribute 'write_pdf'
- 测试
- DOM(文档对象模型)学习笔记(一)
- 工具类网站
- Python使用字符串
- 统计分析/机器学习吐血整理最强指南(第二版)
- 软件工程(C编码实践篇)学习总结
- 四个年龄段统计的患病人数占总患病人数的比例。
- 什么是进程和线程,我读到的最清晰的描述,来自《Reversing:逆向工程揭秘》