Skip to content

Instantly share code, notes, and snippets.

@BastinRobin
Created August 23, 2016 16:08
Show Gist options
  • Select an option

  • Save BastinRobin/920b34644eb97b778f7d90527be018f7 to your computer and use it in GitHub Desktop.

Select an option

Save BastinRobin/920b34644eb97b778f7d90527be018f7 to your computer and use it in GitHub Desktop.
Decision Tree classifier using Python
"""
Machine Learning Classifier Beginner
Classify if the given features is an apple or orange
"""
from sklearn import tree
features = [[140, 1], [130, 1], [150, 0], [170, 0]] # 0 - orange and 1 - apple
labels = [0,0,1,1] # 0 - Orange and 1 - Apple
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print clf.predict([[150, 0]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment