[問題] decision tree畫圖

看板Python作者 (30)時間6年前 (2018/05/03 05:39), 6年前編輯推噓0(006)
留言6則, 2人參與, 6年前最新討論串1/1
最近剛剛學習python 在看到sklearn裡面的決策樹例子(iris) 最後代碼都是存成一個pdf出來 想請問說有辦法在PYTHON裡面顯示出來嗎?(就不另外存pdf出來) 我依照參數設定 from IPython.display import Image dot_data = tree.export_graphviz(clf, out_file=None, feature_names=iris.feature_names, class_names=iris.target_names, filled=True, rounded=True, special_characters=True) graph = pydotplus.graph_from_dot_data(dot_data) Image(graph.create_png()) 總會閃一下 然後就不見了 請問是遇到了什麼問題? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 97.68.49.3 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1525297179.A.EBB.html

05/03 05:56, 6年前 , 1F

05/03 05:56, 6年前 , 2F
這是例子的原代碼
05/03 05:56, 2F

05/03 06:12, 6年前 , 3F
我完全複製sklearn的教學 https://imgur.com/a/xNo3FiP
05/03 06:12, 3F

05/03 06:12, 6年前 , 4F
不知道為什麼也不會出現像例子中的圖
05/03 06:12, 4F

05/04 16:10, 6年前 , 5F
先把 英文 拼對
05/04 16:10, 5F
※ 編輯: mikeliang (73.21.209.15), 05/06/2018 11:50:35

05/06 11:51, 6年前 , 6F
已改 請問樓上能幫我解答嗎?謝謝
05/06 11:51, 6F
文章代碼(AID): #1QwZ0Rwx (Python)