def iris_demo():
clf = tree.DecisionTreeClassifier()
iris = load_iris()
# iris.data??150*4,iris.target ???????0,1,2(150*1)
clf = clf.fit(iris.data, iris.target)
dot_file = 'tree.dot'
tree.export_graphviz(clf, out_file=dot_file)
visualize_tree(clf, iris.feature_names, dot_file)
# (graph,) = pydot.graph_from_dot_file('tree.dot')
# graph.write_png('somefile.png')
评论列表
文章目录