我有一些图像,我试图将特征用于面部识别任务,其中我提取N个面部图像的F个特征,然后尝试测试SVC给出的识别率。每当我拟合我的数据并尝试进行预测时,准确度是得分为0.0,准确率也是。
我尝试预测三个实例:
1-)1张来自5张图像的特征。
from sklearn import metrics
from sklearn.metrics import classification_report
m_array = [[229],
[230],
[231],
[230],
[230.]]
faces = np.array(['Face 1', 'Face2', 'Face 3', 'Face 4', 'Face 5'])
X_train, X_test, y_train, y_test = train_test_split(m_array, faces, test_size = 0.20)
svclassifier = SVC(kernel='linear')
svclassifier.fit(X_train, y_train)
y_pred = svclassifier.predict(X_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
print(confusion_matrix(y_test,y_pred))
print(classification_report(y_test,y_pred))
给我:
precision recall f1-score support Face 1 0.00 0.00 0.00 1.0 Face2 0.00 0.00 0.00 0.0 accuracy 0.00 1.0 macro avg 0.00 0.00 0.00 1.0 weighted avg 0.00 0.00 0.00 1.0
2-)3张10张图片中的特征
m_array_2 = [[229, 233, 234],
[230, 229, 237,],
[231, 229, 237,],
[230, 229, 236,],
[230, 228, 236, ],
[230, 228, 235,],
[229, 228, 236, ],
[230, 227, 238,],
[231, 227, 238,],
[231, 229, 239]
faces = np.array(['Face 1', 'Face2', 'Face 3'])
features_array = (m_array_2[:,:3])
我什至试图说人脸是特征,所以我可以拟合数据,仍然获得与上面相同的结果。
3-)6张15张图片中的特征
发生了同样的事情:
features_array_2 = [[229, 233, 234, 194, 233, 227, 215, 232, 203, 214, 226, 238, 221, 222,
239, 251, 248, 243, 244, 242, 250, 231],
[230, 229, 237, 191, 235, 226, 214, 234, 206, 213, 222, 239, 221, 228,
238, 248, 250, 242, 247, 245, 251, 229],
[231, 229, 237, 193, 232, 226, 214, 236, 206, 215, 220, 239, 221, 228,
236, 248, 250, 242, 247, 244, 252, 230],
[230, 229, 236, 193, 233, 227, 214, 236, 206, 214, 220, 238, 221, 228,
234, 246, 249, 241, 247, 244, 252, 230],
[230, 228, 236, 195, 233, 225, 214, 237, 205, 215, 220, 238, 221, 228,
233, 247, 249, 240, 247, 244, 251, 230],
[230, 228, 235, 195, 233, 225, 214, 237, 205, 215, 219, 238, 220, 228,
234, 242, 249, 241, 247, 244, 251, 230],
[229, 228, 236, 196, 233, 225, 214, 237, 205, 215, 219, 239, 217, 228,
234, 239, 247, 240, 248, 243, 251, 230],
[230, 227, 238, 194, 233, 225, 215, 236, 205, 215, 219, 239, 217, 228,
234, 239, 247, 241, 245, 244, 246, 230],
[231, 227, 238, 196, 233, 226, 215, 237, 207, 215, 219, 239, 217, 229,
234, 237, 247, 240, 244, 244, 246, 230],
[231, 229, 239, 196, 232, 225, 215, 236, 207, 216, 220, 238, 217, 229,
233, 237, 247, 240, 244, 243, 246, 230],
[231, 229, 239, 195, 232, 225, 215, 235, 206, 217, 220, 239, 218, 228,
233, 237, 248, 240, 244, 244, 247, 230],
[229, 233, 234, 194, 234, 226, 215, 232, 208, 214, 227, 239, 221, 222,
239, 251, 248, 242, 248, 241, 250, 230],
[231, 228, 239, 195, 232, 226, 216, 236, 207, 214, 221, 238, 218, 229,
233, 240, 248, 240, 245, 244, 247, 229],
[231, 228, 236, 196, 232, 226, 215, 235, 206, 215, 221, 238, 217, 226,
233, 243, 247, 241, 245, 243, 247, 229],
[232, 228, 236, 196, 232, 226, 215, 236, 207, 215, 221, 238, 217, 226,
231, 246, 247, 240, 246, 242, 247, 230]]
faces = np.array(['Face 1', 'Face2', 'Face 3', 'Face 4', 'Face 5', 'Face 6'])
features_array_2 = (features_array_2[:,:6]).reshape(6, 15)
[[0 1 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 1 0]]
precision recall f1-score support
Face 1 0.00 0.00 0.00 1.0
Face 3 0.00 0.00 0.00 0.0
Face 4 0.00 0.00 0.00 0.0
Face 6 0.00 0.00 0.00 1.0
accuracy 0.00 2.0
macro avg 0.00 0.00 0.00 2.0
weighted avg 0.00 0.00 0.00 2.0
我想做的是从N张图像中获得给定F功能的准确度/准确率,但是无论我做什么,我都会得到相同的结果。