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 !'.

1 Answer 1

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])
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.