1
votes

I'm using LIBSVM toolbox for Matlab. My problem is a binary classification problem with labels of 1 (True) and 0 (False). When I train my system with this function :

svmstruct = svmtrain(TrainTargets, TrainInputs,['-t 2 ' '-g ' SIGMA ' -c ' P ' -q' ' -b 1']);

and test my test accuracy with this function :

[TestOutputs, ~, ~] = svmpredict(TestTargets, TestInputs, svmstruct,'-b 1 -q');

Now I want use desined SVM model for out sample data. So I use this function :

[OUT, ~, Prob_Out] = svmpredict(zeros(size(Outsample_DATA,1),1), Outsample_DATA, svmstruct,'-q -b 1');

For my first trained model (I have trained SVM model with different parameters) I have this Output (Out sample data set is same in both cases) : [Prob_Out OUT]

0.8807    0.1193         0
0.8717    0.1283         0
0.0860    0.9140    1.0000
0.7846    0.2154         0
0.7685    0.2315         0
0.7916    0.2084         0
0.0326    0.9674    1.0000
0.7315    0.2685         0
0.3550    0.6450    1.0000

for second one I have this :

0.4240    0.5760         0
0.4090    0.5910         0
0.7601    0.2399    1.0000
0.5000    0.5000    1.0000
0.4646    0.5354         0
0.4589    0.5411         0

Suppose that I want find class 1 with these probabilities. In first group of data when column 2 is larger than column 1 this sample belongs to class 1 but in second group when column 1 is larger than column 2 the sample belongs to class 1.

The structure of these two out sample data is same. What is the problem?

Thanks.

PS. When I check SVMstruct parameters after training the model in on of these models Label is [0;1] and in another label is [1;0] !

1

1 Answers

1
votes

As you have already noticed, the difference is due to the different mapping of the labels.

LIBSVM uses its own labels internally and therefore needs a mapping between the internal labels and the labels you provided.

The labels in this mapping are generated using the order the labels appear in the training data. So if the label of the first element in your training data changes, the label mapping also changes.