0

I am using LIBSVM SVR for prediction in MATLAB. The output of svmtrain is supposed to be a model which is in this case should be a structure. But sometimes it returns just a single value. Can someone tell me what that mean. Below is one such data for which it returned me a single output value (7.586428304542136e-05)

Input X training instance matrix is
[0.416804048175116;0.725969684480469;0.727160324220360;0.566114850941063;0.718127490039841;0.646792141777717;0.642830974950772;0.748591839538398;0.639923066355269;0.368491551037230] and 
corresponding output Y training instance matrix is
[0.034441805225653;0.030878859857482;0.032066508313539;0.030878859857482;0.030878859857482;0.030878859857482;0.034441805225653;0.023752969121140;0.032066508313539;0.054631828978622]
SVM code:
model = svmtrain(Y,X,['-s 3 -t 2 -c 1 -p 0.001 -g 1 -v 5']);

The values of c and g are varied from 2.^[-6:6].

ChanChow
  • 1,346
  • 7
  • 28
  • 57
  • 1
    can you provide more details of your problem? I don't understand your input and output. Is it a classification problem or a prediction problem? What's your training instance matrix? You may update your question by showing us the whole code. – lennon310 Dec 04 '13 at 14:08
  • There is also an `svmtrain` in Matlab's own Statistics Toolbox. Maybe the two m-files interfer somehow? – A. Donda Dec 04 '13 at 15:45
  • 1
    @lennon310 Hi, thanks for checking the question. It is a regression problem and I am using LIBSVM epsilon svr with rbf kernel. – ChanChow Dec 04 '13 at 22:17

1 Answers1

3

From the libsvm/matlab README:

If the '-v' option is specified, cross validation is conducted and the returned model is just a scalar: cross-validation accuracy for classification and mean-squared error for regression.

This is the only case that I know of in which libsvm should return a scalar from training.

From your post:

model = svmtrain(Y,X,['-s 3 -t 2 -c 1 -p 0.001 -g 1 -v 5']);

That -v 5 on the end causes it to do cross-validation, and then model is a scalar (mse) as noted in the README above.

Dthal
  • 3,216
  • 1
  • 16
  • 10
  • but what I see is most of the times it returns model which in this case is a structure with Parameters,nr_class,totalSV,rho etc. Why is this happening – ChanChow Dec 04 '13 at 23:13
  • If you drop -v 5, you'll get a model instead of a score from cv. With -v 5, you get score from 5-fold cv, but no model. – Dthal Dec 04 '13 at 23:24
  • Thanks for getting back to me. Could you please look into the new question I posted which has more detail – ChanChow Dec 04 '13 at 23:32
  • I also get that number. According to the README, that should be the mean squared error during 5-fold cv, that is, the mean of the squared error between each point's actual value and the prediction made by the model trained on the 4 validation folds that do not include that point. I haven't used libsvm much for regression, but when you call it that way on a classification problem (with -v), it does return cv-accuracy, as stated in the README. – Dthal Dec 04 '13 at 23:58