pythonでsklearnを使用し決定木を試しているのですが、「InvocationException: GraphViz's executables not found」というエラーが出てきます。
このエラーの解消方法をご教示頂けますでしょうか。
宜しくお願いします。
python
1from sklearn.datasets import load_iris 2from sklearn.tree import DecisionTreeClassifier 3from sklearn.tree import export_graphviz 4import pydotplus 5from sklearn.externals.six import StringIO 6 7 8iris = load_iris() 9X = iris.data[:,2:] 10Y = iris.target 11 12tree_clf = DecisionTreeClassifier(max_depth=2) 13tree_clf.fit(X,Y) 14 15 16export_graphviz( 17 tree_clf, 18# out_file=image_path("iris_tree.dot"), 19 out_file="iris_tree.dot", 20 feature_names=iris.feature_names[2:], 21 class_names=iris.target_names, 22 rounded=True, 23 filled=True 24) 25 26# # 作成した決定木を可視化 (pydotplus パッケージを利用) 27dot_data = StringIO() 28export_graphviz(tree_clf, out_file=dot_data) 29graph = pydotplus.graph_from_dot_data(dot_data.getvalue()) 30 31# # PDFファイルに出力 32graph.write_pdf("graph.pdf") 33 34from IPython.display import Image 35Image(graph.create_png())
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/18 06:01
2018/11/18 06:32 編集