1
$\begingroup$

I am currently trying to classify 6 class of facial expression using SVM. I am using MATLAB and LIBSVM to do my classification.

The problem i face is the pred label below produces 0 and 1. It treats it as binary classifer. I am able to do multi-class svm but there is one more step that is voting or sum-pooling which i am not sure how to do it. Need some help in it.

Code:

u=unique(TrainLabel); 
N=length(u); 
if(N>2)    
    itr=1;    
    classes=0;   
    while((classes~=1)&&(itr<=length(u)))   
        c1=(TrainLabel==u(itr));    
        newClass=double(c1); 
        tst = double((TestLabel == itr));
        model = svmtrain(newClass, TrainVec, '-c 1 -g 0.00154');  
        [predict_label, accuracy, dec_values] = svmpredict(tst, TestVec, model);    
        itr=itr+1;   
    end
    itr=itr-1;
end

Any help is appreciated

$\endgroup$
  • $\begingroup$ Isn't it actually a programming-in-MATLAB problem? If so, it should rather go to SO... If you agree, I'll migrate it. $\endgroup$ – user88 Feb 21 '12 at 0:08
1
$\begingroup$

I'm not sure about the exact way to implement this with LIBSVM. Just one think that you should keep in mind, that before you implement the voting you have/might want to check whether this is beneficial for you ? In other words, you need to check whether your SVMs output is "different" enough so voting would be valuable. You can read more about voting in general and specifically about "Measures of Diversity" here: http://users.rowan.edu/~polikar/RESEARCH/PUBLICATIONS/csm06.pdf

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ the reason i asked is because the pred label from the model is either 0 or 1... i want it to have values of 1 to 6... $\endgroup$ – lakesh Jan 21 '12 at 19:42
0
$\begingroup$

No, you won't get single svmtrain output to be anything but binary.

SVMs are inherently binary - they simply create a maximum margin plane that separates the two classes of datapoints.

You'll need to create 6 one-vs-all ({1, 2, 3, 4, 5, 6} => {0, 0, 1, 0, 0, 0}) sort of thing or use more robust methods like ECOC. See my answer here.

| cite | improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.