在学习决策树时,使用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
)