Skip to content

Instantly share code, notes, and snippets.

@vaibhav-jain
Last active July 23, 2017 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaibhav-jain/f0693b6516754ba04fbf0a57dc1ed3c7 to your computer and use it in GitHub Desktop.
Save vaibhav-jain/f0693b6516754ba04fbf0a57dc1ed3c7 to your computer and use it in GitHub Desktop.
Getting Started with Machine Learning using SciKit-learning
#!/usr/bin/env python
# My first Machine Learning Program.
from sklearn import tree
"""
Apple & oranges problem [Weight, Texture]
"""
features1 = [
[140, 0],
[130, 0],
[150, 1],
[170, 1],
]
labels1 = [0, 0, 1, 1]
clf1 = tree.DecisionTreeClassifier()
clf1 = clf1.fit(features1, labels1)
print clf1.predict([[160, 0]])
"""
Sports car & minivan problem [Horse Power, # of Seats]
"""
features2 = [
[1000, 2],
[1500, 1],
[800, 7],
[1000, 5],
]
labels2 = [0, 0, 1, 1]
clf2 = tree.DecisionTreeClassifier()
clf2 = clf2.fit(features2, labels2)
print clf2.predict([[1200, 11]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment