Skip to content

Instantly share code, notes, and snippets.

@dilanshah
Created February 26, 2018 19:03
Show Gist options
  • Save dilanshah/5ad99fa1dc755e8073f76b063b2f6187 to your computer and use it in GitHub Desktop.
Save dilanshah/5ad99fa1dc755e8073f76b063b2f6187 to your computer and use it in GitHub Desktop.
taken from siraj raval's python for data science video #1
# decision tree that creates branches for every possible outcome
from sklearn import tree
# list of lists -- each value is the length, width and shoe size
X = [[181,80,44],[177,70,43],[160,60,38],
[154,54,37],[166,65,40],[190,90,47],
[175,64,39],[177,70,40],[159,55,37],
[171,75,42],[181,85,43]]
Y = ['male', 'female', 'female', 'female', 'male', 'male',
'male', 'female', 'male', 'female', 'male']
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X,Y)
prediction = clf.predict([[190,70,43]])
print(prediction)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment