pythonの決定木グラフの出力がうまくいかず困っております。
決定木自体はできております。
以下のようなエラーが出るのですが、解決方法ありますでしょうか。
python3
1import pydotplus 2from sklearn.externals.six import StringIO 3dot_data = StringIO() 4 5from sklearn import tree 6 7tr = tree.DecisionTreeClassifier(random_state=0) 8tr.fit(X_train, Y_train) 9 10tree.export_graphviz(tr, out_file="tree.dot") 11 12graph = pydotplus.graph_from_dot_data(dot_data.getvalue()) 13
(出力)
^
Expected {'graph' | 'digraph'} (at char 0), (line:1, col:1)
python3
1graph.write_pdf("graph.pdf")
(出力)
AttributeError Traceback (most recent call last)
<ipython-input-102-5f6f2882416d> in <module>()
----> 1 graph.write_pdf("graph.pdf")
AttributeError: 'NoneType' object has no attribute 'write_pdf'
よろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/17 04:08
2018/04/17 04:21
2018/04/17 11:04