Files
FYS-STK4155/doc/Programs/JupyterFiles/Examples/Youtube Tutorials/Digit Recognition Sentdex.ipynb
T
2018-05-06 22:19:59 -04:00

6.3 KiB

In [12]:
import matplotlib.pyplot as plt
import numpy
from sklearn import datasets
from sklearn import svm
digits=datasets.load_digits()

clf=svm.SVC(gamma=0.001, C=100)
print(digits.data)
x,y=digits.data[:-1], digits.target[:-1]
clf.fit(x,y)

print (digits.data)
print (x.shape)

print("prediction:", clf.predict(digits.data))
plt.imshow(digits.images[-2])
plt.show()
[[  0.   0.   5. ...,   0.   0.   0.]
 [  0.   0.   0. ...,  10.   0.   0.]
 [  0.   0.   0. ...,  16.   9.   0.]
 ..., 
 [  0.   0.   1. ...,   6.   0.   0.]
 [  0.   0.   2. ...,  12.   0.   0.]
 [  0.   0.  10. ...,  12.   1.   0.]]
[[  0.   0.   5. ...,   0.   0.   0.]
 [  0.   0.   0. ...,  10.   0.   0.]
 [  0.   0.   0. ...,  16.   9.   0.]
 ..., 
 [  0.   0.   1. ...,   6.   0.   0.]
 [  0.   0.   2. ...,  12.   0.   0.]
 [  0.   0.  10. ...,  12.   1.   0.]]
(1796, 64)
prediction: [0 1 2 ..., 8 9 8]
In [ ]:
In [ ]: