def visualize_tree(clf, outname, headers):
from sklearn.externals.six import StringIO
import pydot
dot_data = StringIO()
tree.export_graphviz(clf, out_file=dot_data, feature_names=list(headers))
graph = pydot.graph_from_dot_data(dot_data.getvalue().decode('latin1').encode('utf8'))
graph.write_pdf(outname)
评论列表
文章目录