Skip to content

Instantly share code, notes, and snippets.

@theSekyi
Created May 17, 2019 11:05
Show Gist options
  • Select an option

  • Save theSekyi/76f0c6219ebce883676672e76257e96a to your computer and use it in GitHub Desktop.

Select an option

Save theSekyi/76f0c6219ebce883676672e76257e96a to your computer and use it in GitHub Desktop.
import os
from PIL import Image
path = '.'
from IPython.display import Image
from sklearn.tree import export_graphviz
from matplotlib.pyplot import imshow
def image_path(fig):
return os.path.join(path,fig)
export_graphviz(
tree_classifier,
out_file=image_path("wine.dot"),
feature_names=list(df_x.drop('quality',axis=1)),
class_names=['C', 'D', 'E', 'B', 'F', 'A'],
rounded=True,
filled=True
)
!dot -Tpng wine.dot -o wine.png
Image(filename='wine.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment