我試圖運行下面的代碼沒有屬性「graph_from_dot_data」:AttributeError的:模塊「pydot」在Spyder的
from sklearn.datasets import load_iris
from sklearn import tree
import pydot
clf = tree.DecisionTreeClassifier()
iris = load_iris()
clf = clf.fit(iris.data, iris.target)
from sklearn.externals.six import StringIO
from pydot import *
dotfile = StringIO()
tree.export_graphviz(clf, out_file = dotfile)
pydot.graph_from_dot_data(dot_data.getvalue()).write_png("dtree2.png")
,我也得到了以下錯誤: AttributeError的:模塊「pydot」有沒有屬性'graph_from_dot_data'
我已經盡力找到解決方案,但無法做到這一點。在這方面請有人幫助我。
嘗試更新您的pydot包 – Arseniy
阿爾謝尼,我試圖installe更新軟件包,如pydotplus和pydot2但無濟於事。你能告訴我這個嗎? –
獲取模塊路徑: 在'pydot.graph_from_dot_data'之前加上'print pydot .__ file__'並檢查路徑是否正確 – Arseniy