[英]Why is the predicted_label +1 even though it should be -1? Using LIBSVM in MATLAB
I extracted the principal components of training and testing data.我提取了训练和测试数据的主要成分。
'trainingdata.train' has feature values from both +1(face 1) and -1(all other faces) labels. 'trainingdata.train' 具有来自 +1(人脸 1)和 -1(所有其他人脸)标签的特征值。 'testdata.train' has feature values from face 2 and no label since i want the SVM to predict its label.
'testdata.train' 具有来自 face 2 的特征值并且没有标签,因为我希望 SVM 预测它的标签。 The "predicted_label" given by LIBSVM is +1 even though it should be -1.
LIBSVM 给出的“predicted_label”是 +1,即使它应该是 -1。
[training_label_matrix, training_instance_matrix] = libsvmread('trainingdata.train');
[testing_label_matrix, testing_instance_matrix] = libsvmread('testdata.train');
model = svmtrain(training_label_matrix, training_instance_matrix);
[predicted_label] = svmpredict(testing_label_matrix, testing_instance_matrix, model);
Please point me out to what i am doing wrong.请指出我做错了什么。
Use [predict_label, accuracy, prob_values] = svmpredict(testLabel, testData, model, '-b 1');
使用
[predict_label, accuracy, prob_values] = svmpredict(testLabel, testData, model, '-b 1');
to observe the accuracy.以观察准确性。
testLabel
is the vector that includes the 'correct' labels of your test data. testLabel
是包含测试数据“正确”标签的向量。 This parameter is given in order to calculate the accuracy
.给出这个参数是为了计算
accuracy
。 In the real case that labels of test data are unknown, simply use any random values to get the predict_label
without calculating the accuracy
.在测试数据标签未知的实际情况下,只需使用任何随机值即可获得
predict_label
而不计算accuracy
。
Besides, although not required, you'd better specify the options in svmtrain
, check their page for more details.此外,虽然不是必需的,但您最好在
svmtrain
指定选项,查看他们的页面以获取更多详细信息。
@Lennon : So should the code go like this? @Lennon:那么代码应该像这样吗?
[training_label_matrix, training_instance_matrix] = libsvmread('trainingdata.train');
[testing_label_matrix, testing_instance_matrix] = libsvmread('testdata.train');
model = svmtrain(training_label_matrix, training_instance_matrix);
[predict_label, accuracy, prob_values] = svmpredict(ones(size(testData,1),1), testing_instance_matrix, model, '-b 1');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.