Skip to content

Instantly share code, notes, and snippets.

@emmagrimaldi
Created September 10, 2018 15:07
Show Gist options
  • Select an option

  • Save emmagrimaldi/e6fd6d1e7c532cab466cd978a2bc9224 to your computer and use it in GitHub Desktop.

Select an option

Save emmagrimaldi/e6fd6d1e7c532cab466cd978a2bc9224 to your computer and use it in GitHub Desktop.
from sklearn.externals.six import StringIO
from sklearn.tree import export_graphviz
import pydotplus
from IPython.display import Image
dot_data = StringIO()
export_graphviz(
model,
out_file = dot_data,
filled=True, rounded=True, proportion=False,
special_characters=True,
feature_names=X.columns,
class_names=["cat", "dog"]
)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment