Skip to content

Instantly share code, notes, and snippets.

@rahulrkroy
Created March 25, 2018 04:29
Show Gist options
  • Select an option

  • Save rahulrkroy/2ab5ecb2e280af5fa72e5f1c384eee1b to your computer and use it in GitHub Desktop.

Select an option

Save rahulrkroy/2ab5ecb2e280af5fa72e5f1c384eee1b to your computer and use it in GitHub Desktop.
just basic supervised type ML with python3 on <linux
#!/usr/bin/python3
#supervised ML apple & orange
# assume smooth =0 and bumpy=1
from sklearn import tree
import os
smooth=0
bumpy=1
features =[[120,smooth],[130,smooth],[140,bumpy],[150,bumpy]]
label=["apple","apple","orange","orange"]
algo=tree.DecisionTreeClassifier()
trained=algo.fit(features,label)
x=[[129,bumpy]]
output=trained.predict(x)
print(output[0])
sound="echo "+str(output[0])+" | festival --tts"
print("sound=",sound)
os.system(sound)
if(output=="apple"):
print("apple show")
os.system('eog apple.png')
else:
print("orange show")
os.system('eog orange.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment