Created
April 16, 2014 17:13
-
-
Save sagz/10908945 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
# Decision Tree Classifier | |
from sklearn import datasets | |
from sklearn import metrics | |
from sklearn.tree import DecisionTreeClassifier | |
# load the iris datasets | |
dataset = datasets.load_iris() | |
# fit a CART model to the data | |
model = DecisionTreeClassifier() | |
model.fit(dataset.data, dataset.target) | |
print(model) | |
# make predictions | |
expected = dataset.target | |
predicted = model.predict(dataset.data) | |
# summarize the fit of the model | |
print(metrics.classification_report(expected, predicted)) | |
print(metrics.confusion_matrix(expected, predicted)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment