我从train数据集中的图像中提取了一些特征,然后应用了这些特征,并使用train_test_split将数据拆分为train和test:Train data : (60, 772)
Test data : (20, 772)
Train labels: (60,)
Test labels : (20,)
接下来我要做的是将支持向量机分类器应用于测试数据集中的图像,并查看结果。在
^{pr2}$
我没有得到很好的准确性,虽然我可以看到它说60%的准确率。然而,大多数图像的标签都不正确。我在prediction中传递了错误的参数吗?在
我能做些什么来改善这一点?在
编辑:我尝试过您用下面的代码所说的,但是我得到一个错误,说我应该重塑我的feature_vector。所以我这样做了,然后得到了以下错误。在
(作为参考:feature_extraction_method(image).shape是(772,)。)for filename in test_images:
# read the image and resize it to a fixed-size
img = cv2.imread(filename)
img = cv2.resize(img, fixed_size)
feature_vector = feature_extraction_method(img)
prediction = clf.predict(feature_vector.reshape(-1, 1))
cv2.putText(img, prediction, (20, 30), cv2.FONT_HERSHEY_TRIPLEX, .7 , (0,