最初にインストール
1 2 |
pip install pydotplus brew install graphviz |
1 2 3 4 5 6 7 8 9 10 11 |
#可視化 import pydotplus from IPython.display import Image from graphviz import Digraph from sklearn.externals.six import StringIO dot_data = StringIO() tree.export_graphviz(clf, out_file=dot_data,feature_names=train_X.columns, max_depth=3) graph = pydotplus.graph_from_dot_data(dot_data.getvalue()) graph.write_pdf("graph.pdf") Image(graph.create_png()) |