0
votes

I am doing some classification task with Support Vector Machines (SVM). I am using libSVM (with Matlab support) to predict probability estimates matrix. However, the libSVM displays message that; Model does not support probabiliy estimates Below is my sample code; (train_label contains labels for training data and test_label contains label for test data)

    model = svmtrain(train_label, train_data, '-t 2 -g .01 -c 0.7 -b 1);
    [y,accuracy,prob_estimates]=svmpredict(test_label,test_data,model,'-b 1');

Can someone tell me if there is something wrong with the way I am doing it? Any help/suggestion will be appreciated.

6

6 Answers

0
votes

Don't know about the Matlab implementation, but usually you have to set this option:

-b probability_estimates: whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)

0
votes

I am using libsvm in the same way without any problem.

In your code only a ' is missing in the following line

model = svmtrain(train_label, train_data, '-t 2 -g .01 -c 0.7 -b 1);

It should be

model = svmtrain(train_label, train_data, '-t 2 -g .01 -c 0.7 -b 1');
0
votes

I had the same problem, model hasn't got ProbA and ProbB in it. Before it was like this and giving error:

linear_model = svmtrain(trainClass, trainData, ['-t 0', cmd]);

Then I changed it to this, error dissappared:) - removed cmd and put exact values

linear_model = svmtrain(trainClass, trainData, ['-t 0 -c 1 -g 0.125 -b 1']); 

if still gives error try to change c and g parameters.

Hope this helps.

0
votes

It is because your model does not support probabiliy estimates.

You should use '-b 1' option both at training and testing process.

See also: https://stackoverflow.com/a/43509667/7893127

0
votes

You may just train the model with default parameter. Try to use '-b 1' when you are training and testing programe.

0
votes

C:\setup\python36\Lib\site-packages\svm.py default value of self.probability is 0. You can set it 1.

enter image description here