Skip to content

Instantly share code, notes, and snippets.

@saiumesh535
Last active July 17, 2017 06:13
Show Gist options
  • Save saiumesh535/47f864e747062ecff1b1af5c625c92d0 to your computer and use it in GitHub Desktop.
Save saiumesh535/47f864e747062ecff1b1af5c625c92d0 to your computer and use it in GitHub Desktop.
Sklearn Python Example
# source https://www.youtube.com/watch?v=cKxRvEZd3Mw
from sklearn import tree;
# 0 for bumpy
# 1 for smooth
features = [[140,1], [130,1], [150,0], [170,0]]
#0 for apple
#1 for orange
labels = [0 ,0, 1, 1];
# this is for classifier
# for now this is empty box of rules
clf = tree.DecisionTreeClassifier();
# fit() helps us in finding patterns in taining data
clf = clf.fit(features, labels);
# now lets predict the fruit first input is weight and second is bumpty or smooth
clf = clf.predict([[143, 1]]);
# if you see the output it will give you whether its Apple or Orange
print(clf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment