为什么精度为0%? MATLAB LIBSVM [英] Why is the accuracy coming as 0% ? MATLAB LIBSVM

查看:163
本文介绍了为什么精度为0%? MATLAB LIBSVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下方法提取了 PCA 功能:

I extracted PCA features using:

function [mn,A1,A2,Eigenfaces] = pca(T,f1,nf1) 
m=mean(T,2),   %T is the whole training set
train=size(T,2);
A=[];
for i=1:train
    temp=double(T(:,i))-m;
    A=[A temp];
end

train=size(f1,2);    %f1 - Face 1 images from training set 'T'
A=[];
for i=1:train
    temp=double(f1(:,i))-m;
    A1=[A1 temp];
end


train=size(nf1,2);    %nf1 - Images other than face 1 from training set 'T'
A=[];
for i=1:train
    temp=double(nf1(:,i))-m;
    A2=[A2 temp];
end

L=A'*A;
[V D]=eig(L);
for i=1:size(V,2)
    if(D(i,i)>1)
       L_eig=[L_eig V(:,1)];
    end
end 
Eigenfaces=A*L_eig;
end  

然后我从这样的训练数据中仅投影出脸1(+1类):

Then i projected only the face 1(class +1) from training data as such :

功能1

for i=1:15                       %number of images of face 1 in training set
    temp=Eigenfaces'*A1(:,i);
    proj_img1=[proj_img1 temp];
end

然后我从训练数据中投影出其余的脸(-1级):

Then i projected rest of the faces(class -1) from training data as such :

功能2

 for i=1:221              %number of images of faces other than face 1 in training set
      temp=Eigenfaces'*A2(:,i);
      proj_img2=[proj_img2 temp];
 end

功能3 然后使用以下命令获得输入图像向量:

Function 3 Then the input image vector was obtained using:

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

我将函数1和2的结果分别写入了带有标签+1和-1的CSV文件中. 然后,当我给出真实标签时,我使用LIBSVM来获得准确性,它返回0%,而当我试图预测标签时,它是-1而不是+1.

I wrote the results of Function 1 and 2 in a CSV file with labels +1 and -1 respectively. I then used LIBSVM to obtain the accuracy when giving the true label, it returned 0% and when i tried to predict the label it was -1 instead of +1.

准确度为0%吗?

基本上,我的模型没有经过适当的训练,我无法看到错误.

Basically my model is not trained properly and i am failing to see the error.

任何建议将不胜感激.

Any suggestions will be greatly appreciated.

推荐答案

使用Eigenfaces作为训练集,组成具有1或-1s的label向量(如果Eigenfaces的第i列引用1,那么label中的ith元素为1,否则为-1).并在svmtrain函数中使用Eigenfaceslabel.

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.

这篇关于为什么精度为0%? MATLAB LIBSVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆