Last active
August 29, 2015 14:26
-
-
Save vaclavcadek/390ea0351b4db30ea6e9 to your computer and use it in GitHub Desktop.
Vizualize sklearn decision tree using graphviz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.externals.six import StringIO | |
from sklearn import tree | |
from graphviz import Source | |
from IPython.display import SVG | |
def vizualize_tree(model, figsize=(14,8)): | |
out = StringIO() | |
tree.export_graphviz(model, out_file=out) | |
graph = Source(out.getvalue()) | |
graph.format = 'svg' | |
graph.render(cleanup=True) | |
return SVG(filename='Source.gv.svg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment