Created
August 23, 2016 16:08
-
-
Save BastinRobin/920b34644eb97b778f7d90527be018f7 to your computer and use it in GitHub Desktop.
Decision Tree classifier using Python
This file contains hidden or 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
| """ | |
| 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