Last active
October 17, 2017 21:32
-
-
Save crawles/556b0d56852c493a1388274cc8932135 to your computer and use it in GitHub Desktop.
Plot a sklearn decision tree
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
import pydot | |
from IPython.display import Image | |
from sklearn.externals.six import StringIO | |
from sklearn.tree import export_graphviz | |
dot_data = StringIO() | |
export_graphviz(cl, out_file=dot_data, | |
feature_names=Xtrain.columns, | |
class_names=['class0','class1'], | |
filled=True, rounded=True, | |
special_characters=True) | |
graph = pydot.graph_from_dot_data(dot_data.getvalue())[0] | |
Image(graph.create_png()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment