1
這是我實施OCR爲號。Sklearn SVM預測值相同
#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
這是我的輸出
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
平均/總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「]
爲什麼我得到相同的預測值。我通過隨機培訓和測試數據 我曾嘗試調試,但我沒有發現我的code.please幫助中的任何問題。