-
-
Save JonathanLoscalzo/fa16747e269d360a0a92e1615f75287d to your computer and use it in GitHub Desktop.
This file contains 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.datasets import * | |
from sklearn import tree | |
import graphviz | |
wine = load_wine() | |
clf = tree.DecisionTreeClassifier() # init the tree | |
clf = clf.fit(wine.data, wine.target) # train the tree | |
# export the learned decision tree | |
dot_data = tree.export_graphviz(clf, out_file=None, | |
feature_names=wine.feature_names, | |
class_names=wine.target_names, | |
filled=True, rounded=True, | |
special_characters=True) | |
graph = graphviz.Source(dot_data) | |
graph.render("wine") # tree saved to wine.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment