python-2.7 – export_graphviz中的“class_names”意外关键字错
发布时间:2020-12-20 11:47:25 所属栏目:Python 来源:网络整理
导读:使用以下代码: classes = ['ham','spam']dot_data = StringIO()with open("./plots/ritesh.dot","w") as f: export_graphviz(dt_old.named_steps['classifier'],out_file=f,feature_names=vocab1,class_names=classes) 我收到错误作为意外的关键字参数. Tra
使用以下代码:
classes = ['ham','spam'] dot_data = StringIO() with open("./plots/ritesh.dot","w") as f: export_graphviz(dt_old.named_steps['classifier'],out_file=f,feature_names=vocab1,class_names=classes) 我收到错误作为意外的关键字参数. Traceback (most recent call last): File "DecisionTree.py",line 198,in <module> main() File "DecisionTree.py",line 133,in main export_graphviz(dt_old.named_steps['classifier'],class_names=classes) TypeError: export_graphviz() got an unexpected keyword argument 'class_names' 但是在scikit-learn doc中明确提到了这一点 sklearn.tree.export_graphviz(decision_tree,out_file='tree.dot',max_depth=None,feature_names=None,class_names=None,label='all',filled=False,leaves_parallel=False,impurity=True,node_ids=False,proportion=False,rotate=False,rounded=False,special_characters=False) TypeError的原因是什么? 解决方法
您安装的sklearn版本可能与文档过时了. 如果您使用anaconda安装了sklearn,请尝试在命令行上运行 “conda update scikit-learn”
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |