Why is the accuracy coming as 0% ? MATLAB LIBSVM

杀马特。学长 韩版系。学妹 提交于 2019-11-29 12:49:09

Use Eigenfaces as the training set, compose a label vector with 1 or -1s (if the ith column of Eigenfaces refers to 1, then the ith element in label is 1, otherwise it is -1) . And use Eigenfaces and label in svmtrain function.

@lennon310:

for i=1:length(Eigenfaces)                   
    temp=Eigenfaces'*A(:,i);
    proj_imgs=[proj_imgs temp];
end

@lennon310:

   diff=double(inputimg)-mn;   %mn is the mean of training data

   testfeaturevector=Eigenfaces'*diff;

Frankly, your code is a mess.

One questionable part:

data = reshape(data, M*N,1);

Doesn't this make data a matrix with just 1 column? This does not make sense.

Look at this tutorial on eigenfaces. There is code and examples within it to show you what to do. See the related webpage here for more details. The Matlab/Octave code can be found here.

@lennon310: 

    temp=double(testimg)-m;  %where 'm' is the mean of the training images
    L=temp'*temp;
    [V D]=eig(L);
    for i=1:size(V,2)
        if(D(i,i)>1)
           L_eig=[L_eig V(:,1)];
        end
    end 
    Eigenfaces=temp*L_eig;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!