在学习决策树时,使用jupyter运行下面代码报错
dot_data =tree.export_graphviz(clf
,feature_names=feature_name
,class_names= ["琴酒","雪莉","贝尔摩德"]
,filled=True
,rounded=True
)
graph=graphviz.Source(dot_data)
graph
报错:
AttributeError: 'NoneType' object has no attribute 'splitlines'
可在tree.export_graphviz()加上out_file=None
即
dot_data =tree.export_graphviz(clf
,feature_names=feature_name
,class_names= ["琴酒","雪莉","贝尔摩德"]
,filled=True
,rounded=True
,out_file=None
)
文章讲述了在使用Python的决策树库进行可视化时,遇到`AttributeError:NoneTypeobjecthasnoattributesplitlines`的问题,解决方案是在`tree.export_graphviz`函数中添加`out_file=None`参数。
9070

被折叠的 条评论
为什么被折叠?



