土豆芝士. 2022-09-15 11:40 采纳率: 25%
浏览 30
已结题

请问为什么运行不出来啊

img


上课时候teacher用pycharm运行出来了我用jupyter notebook运行没反应
代码如下:
from sklearn.datasets import load_iris
from sklearn import tree
import pydotplus
iris = load_iris()
X = iris.data
y = iris.target
clf = tree.DecisionTreeClassifier(max_depth=4)
clf = clf.fit(X, y)
dot_data = tree.export_graphviz(clf, out_file=None,
class_names=iris.target_names,
filled=True, rounded=True,
special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data)
f = open('tree.png','wb')
#f = open('tree.pdf', 'wb')
f.write(graph.create_png())
#f.write(graph.create_pdf())
f.close()

  • 写回答

2条回答 默认 最新

  • Cleansely 2022-09-15 12:00
    关注

    是没运行起来吗,有报错什么的吗

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 9月17日
  • 修改了问题 9月15日
  • 创建了问题 9月15日