3

I have been trying to build SVM classifier but having trouble with predict.

>  modelrbf<-ksvm(set,y,kernel="rbfdot",type="C-svc")  
Using automatic sigma estimation (sigest) for RBF or laplace kernel  
> predict(modelrbf,set[24,])  
Error in .local(object, ...) : test vector does not match model !

I am clueless What is causing the error: 'test vector does not match model !'.

Vincent Zoonekynd
  • 31,893
  • 5
  • 69
  • 78
jitendra
  • 1,438
  • 2
  • 19
  • 40

1 Answers1

7

The default behavior of [ is to coerse the result to the lowest possible dimension, which means if you try to select only one row you actually end up with a vector. I always bump into this problem myself. Try this instead:

predict(modelrbf,set[24,, drop=FALSE])
joran
  • 169,992
  • 32
  • 429
  • 468
John Colby
  • 22,169
  • 4
  • 57
  • 69