I'm getting the following error from Liblinear while trying to train an SVM: 'Error: C<= 0'. Although it's obvious what's wrong, I can't figure out why there is a problem, since the C I find through cross validation is positive.
This is the cross validation code (I have removed the lower bit) for finding C
for log2c = 2:1:6,
cmd = ['-s 2 -v 5 -c ', num2str(2^log2c)];
cv = train(labels, features, cmd);
and the result I get is
Cross Validation Accuracy = 91.6772%
bestc = 4, cv = 91.6772
However when I then train the SVM I get
models{i} = train(trainLabel, trainFeats, ['-s 2 -c ', bestc]);
Error: C <= 0
If anyone has any suggestions they would be much appreciated!
(Also, my data is roughly 2/3 negative and 1/3 positive if that is of any use)
I think you should write:
models{i} = train(trainLabel, trainFeats, ['-s 2 -c ', num2str(bestc)]);
Also ensure that value of bestc
is positive i.e. >=0