jupyter error: can't view decision tree as png in random forest
jupyter error: can't view decision tree as png in random forest
我正在尝试在 Jupyter Notebook 中查看我的决策树。我已经安装了 graphviz(在 anaconda cmd 提示符下)和 pydot。
#taking one tree from the forest and saving it as an image
#!pip install graphviz
from sklearn.tree import export_graphviz
#!pip install pydot
import pydot
#pulling out one tree from the forest
tree = rf.estimators_[5]
#export one image to a dot file
feature_list = list(feature.columns)
export_graphviz(tree, out_file = 'tree.dot', feature_names = feature_list,
rounded = True, precision = 1)
#use dot file to create a graph
(graph, ) = pydot.graph_from_dot_file('tree.dot')
#write graph to a png file
graph.write_png('tree.png')
最后一行 运行s 成功,没有任何输出。
然后我 运行 anaconda 命令提示符中的代码:
dot -Tpng tree.dot -o tree.png
并得到错误:
Error: dot: can't open tree.dot1
我正在使用 windows 机器。
图片在我的下载文件夹中可用。
我正在尝试在 Jupyter Notebook 中查看我的决策树。我已经安装了 graphviz(在 anaconda cmd 提示符下)和 pydot。
#taking one tree from the forest and saving it as an image
#!pip install graphviz
from sklearn.tree import export_graphviz
#!pip install pydot
import pydot
#pulling out one tree from the forest
tree = rf.estimators_[5]
#export one image to a dot file
feature_list = list(feature.columns)
export_graphviz(tree, out_file = 'tree.dot', feature_names = feature_list,
rounded = True, precision = 1)
#use dot file to create a graph
(graph, ) = pydot.graph_from_dot_file('tree.dot')
#write graph to a png file
graph.write_png('tree.png')
最后一行 运行s 成功,没有任何输出。
然后我 运行 anaconda 命令提示符中的代码:
dot -Tpng tree.dot -o tree.png
并得到错误:
Error: dot: can't open tree.dot1
我正在使用 windows 机器。
图片在我的下载文件夹中可用。