【发布时间】:2012-02-07 05:59:17
【问题描述】:
我正在关注此页面上的示例:Example of 10-fold SVM classification in MATLAB。
基本上,我正在按照示例执行我的分类。我面临的问题是 pred 总是积极的。它无法检测到负数据。
clear all;
clc;
load('C:\Users\HP\Documents\MATLAB\TrainLabel');
load('C:\Users\HP\Documents\MATLAB\TrainVec');
cvFolds = crossvalind('Kfold', TrainLabel, 10);
cp = classperf(TrainLabel);
for i = 1:10
testIdx = (cvFolds == i);
trainIdx = ~testIdx;
% Model = svmtrain(TrainVec(trainIdx,:), TrainLabel(trainIdx),'showplot',true);
Model = svmtrain(TrainVec(trainIdx,:), TrainLabel(trainIdx), ...
'Autoscale',true, 'Showplot',false, 'Method','QP', ...
'BoxConstraint',2e-1, 'Kernel_Function','rbf', 'RBF_Sigma',1);
pred = svmclassify(Model, TrainVec(testIdx,:),'Showplot',false);
cp = classperf(cp, pred, testIdx);
end
cp.CorrectRate
cp.CountingMatrix
pred 的值为 [1;1;1;1;1;1],但我的正确率是 0.65(65%),TrainLabel 是 ,TrainVec 是 。
另外两个qns:
TrainLabel 的值必须是 0 和 1 吗?是-1还是1可以吗
TrainVec 使得图像中的每个特征都放置在一行中。下一张图像中的特征放置在下一行。它是否正确?还是必须将每个功能放在不同的列中?
在这方面需要一些帮助...谢谢
【问题讨论】:
标签: validation matlab computer-vision svm