Вопрос

This is my implementation for ocr for number.

#mix the dataset
dataset=np.delete(dataset,0,0)
lable=np.delete(lable,0)
X=dataset.shape[0]
l=range(X)
np.random.shuffle(l)


sampleing=np.zeros(32*32)
lableing=np.zeros(1)

for x in l:
    sampleing=np.vstack((sampleing,dataset[x]))
    lableing=np.hstack((lableing,lable[x]))

sampleing=np.delete(sampleing,0,0)
lableing=np.delete(lableing,0)
x=sampleing.shape[0]
train=sampleing[0:int(x*0.8)]
train_lableing=lableing[0:int(x*0.8)]
test=sampleing[int(x*0.8):]
test_lableing=lableing[int(x*0.8):]

clf=svm.SVC(gamma=0.001, C=100.)

print clf.fit(train,train_lableing)
predict=clf.predict(test)
print classification_report(test_lableing,predict)

print predict

This is my output

     precision    recall  f1-score   support

      0       0.00      0.00      0.00         9
      1       0.00      0.00      0.00        14
      2       0.00      0.00      0.00         6
      3       0.00      0.00      0.00         5
      4       0.00      0.00      0.00         4
      5       0.00      0.00      0.00         3
      6       0.00      0.00      0.00        10
      7       0.00      0.00      0.00        12
      8       0.17      1.00      0.29        15
      9       0.00      0.00      0.00        10

avg / total 0.03 0.17 0.05 88

['8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8' '8']

Why am i getting same predict value.I am passing random training and testing data I did try to debug but i did not find any problem in my code.please help.

Это было полезно?

Решение

This could because of few number of dataset(feature) .SVC work well with large data set.Try using LinerSVC this should solve the problem.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top