亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

解決使用export_graphviz可視化樹(shù)報(bào)錯(cuò)的問(wèn)題

 更新時(shí)間:2019年08月09日 14:56:04   作者:lzher0  
今天小編就為大家分享一篇解決使用export_graphviz可視化樹(shù)報(bào)錯(cuò)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

在使用可視化樹(shù)的過(guò)程中,報(bào)錯(cuò)了。說(shuō)是‘dot.exe'not found in path

原代碼:

# import tools needed for visualization
from sklearn.tree import export_graphviz
import pydot
 
#Pull out one tree from the forest
tree = rf.estimators_[5]
 
# Export the image to a dot file
export_graphviz(tree, out_file = 'tree.dot', feature_names = features_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');

報(bào)錯(cuò)信息:

解決方法:

先使用安裝pydot:

pip install pydot

然后再下載Graphviz(http://www.graphviz.org 選擇msi版本)一路安裝,記住默認(rèn)的安裝路徑

c:\Program Files (x86)\Graphviz2.38\。

將Graphviz2.38添加到環(huán)境變量中

import os
os.environ['PATH'] = os.environ['PATH'] + (';c:\\Program Files (x86)\\Graphviz2.38\\bin\\')

之后便可以正常使用了。

修改后代碼:

# import tools needed for visualization
from sklearn.tree import export_graphviz
import pydot
import os
 
os.environ['PATH'] = os.environ['PATH'] + (';c:\\Program Files (x86)\\Graphviz2.38\\bin\\')
 
#Pull out one tree from the forest
tree = rf.estimators_[5]
 
# Export the image to a dot file
export_graphviz(tree, out_file = 'tree.dot', feature_names = features_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');

以上這篇解決使用export_graphviz可視化樹(shù)報(bào)錯(cuò)的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論