3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jupyter Notebook(iPython Notebook)内でscikit-learnの決定木(graphvizの.dotファイル)を表示する

Posted at

pydotplusというライブラリを使うとできる

pip install pydotplus
import pydotplus
dot_data = StringIO()

tree.export_graphviz(
  classifier, 
  out_file=dot_data, 
  feature_names=feature_names, 
  class_names=["False","True"], 
  filled=True, 
  rounded=True,  
  special_characters=True
)

graph = pydotplus.graph_from_dot_data(
  dot_data.getvalue()
)
Image(graph.create_png())

いちいち、.dotファイルからpngファイルへの書き換えコマンドを打たなくてすむようになった

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?