小编Wei*_*ang的帖子

'DecisionTreeClassifier' 对象没有属性 'export_graphviz'

我正在使用 python sklearn RandomForestClassifier 并尝试导出决策树。

基本代码如下:

from sklearn import tree

with open(dot_file_name, 'w') as my_file:
    tree.export_graphviz(tree1, out_file = my_file,feature_names = feature_names)
Run Code Online (Sandbox Code Playgroud)

运行python脚本后,出现以下错误:属性错误:'DecisionTreeClassifier'对象没有属性'export_graphviz'

我正在使用 python 2.7。是因为python的版本吗?我必须使用python 3.0吗?

python random-forest scikit-learn

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

random-forest ×1

scikit-learn ×1