1

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

lakshmen
  • 1,045
  • 4
  • 12
  • 26
  • Isn't it actually a programming-in-MATLAB problem? If so, it should rather go to SO... If you agree, I'll migrate it. –  Feb 21 '12 at 00:08

2 Answers2

1

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

Dov
  • 1,630
  • 3
  • 14
  • 24
  • 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... – lakshmen Jan 21 '12 at 19:42
0

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.

lollercoaster
  • 2,016
  • 1
  • 17
  • 15