获取 SVM 预测错误的图像名称

Getting Name of Images at which SVM mispredicted

我正在研究二元分类模型,我想知道模型预测错误的图像的名称。我该怎么做?

to_be_moved = random.sample(glob.glob("/content/COVID-19_Radiography_Dataset/COVID/images/*.png"), 1500)

label= 0
for img in tqdm(to_be_moved):
    imgstate= cv2.imread(img,0)
    resizedimage=cv2.resize(imgstate,(220,220))
    fd = hog(resizedimage, orientations=9, pixels_per_cell=(2, 2),cells_per_block=(1,1), visualize=False, multichannel=False)
    data.append([fd,label])


random.shuffle(data)
features= []
labels=[]
for feature , label in data :
  features.append(feature)
  labels.append(label) 

from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
X_train , X_test , y_train , y_test = train_test_split(features,labels, test_size=0.25)
model = SVC(C=1,kernel='linear',gamma ='auto' )
model.fit(X_train , y_train)

您可以扩展数据元组以包含 fd 、 pathofimage 和标签。然后在拆分之后,你可以在训练、测试、拆分之后划分元组,这样你将得到路径以及它预测的图像。记住将随机播放设置为 False