决策树出图报错
来源:6-5 分类-决策树

骨折不补钙
2018-11-19
老师,在跑graphviz的时候报错了显示
NotFittedError: This KNeighborsClassifier instance is not fitted yet. Call ‘fit’ with appropriate arguments before using this method.
代码如下:
dot_data=StringIO()
export_graphviz(clf,out_file=dot_data,
feature_names=f_names,
class_names=[“NL”,“L”],
filled=True,
rounded=True,
special_characters=True)
graph=pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf(“dt_tree.pdf”)
之前fit过了,在不加这串代码的情况下没有报错,这是什么情况不是太明白。
写回答
1回答
-
骨折不补钙
提问者
2018-11-20
已解决,之前把其他模型也导入了
00
相似问题