SHARE
TWEET

Untitled

a guest Jun 18th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from sklearn import datasets
  2. from sklearn.svm import SVC
  3. from scipy import misc
  4.  
  5. import os
  6. os.system('sudo pip install scikit-learn')
  7.  
  8.  
  9. digits = datasets.load_digits()
  10. features = digits.data
  11. labels = digits.target
  12.  
  13. clf = SVC(gamma = 0.001)
  14. clf.fit(features, labels)
  15.  
  16.  
  17. img = misc.imread("8.jpg")
  18. img = misc.imresize(img, (8,8))
  19. img = img.astype(digits.images.dtype)
  20. img = misc.bytescale(img, high=16, low=0)
  21.  
  22.  
  23. x_test = []
  24.  
  25. for eachRow in img:
  26.     for eachPixel in eachRow:
  27.         x_test.append(sum(eachPixel)/3.0)
  28.  
  29.  
  30.  
  31. print(clf.predict([x_test]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top