I have a multiclass svm classification(6 class). I would like to classify it using LIBSVM. The following are the ones that i have tried and i have some questions regarding them.
Method1( one vs one):
model = svmtrain(TrainLabel, TrainVec, '-c 1 -g 0.00154 -b 0.9');
[predict_label, accuracy, dec_values] = svmpredict(TestLabel, TestVec, model);
Two questions about this method: 1) is that all i need to do for multiclass problem 2) what value should it be for n in '-b n'. I m not sure
Method 2( one vs rest):
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
For the second method,how do I attach classification scores. I am not able to do voting.
Besides that,these are the two methods I have tried. Which method is better?
Would like to hear some comments. Please correct me if I am wrong.
Regarding the '-b' parameter, in the LIBSVM README it says:
-b probability_estimates: whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)
Therefore, you should specify '-b 1' if you want the trained model to return class probabilities, and '-b 0' if you don't. You only need to call
svmtrain
once. Also, if you specify '-b 1' for training, you must also specify it for prediction.