Question

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

Was it helpful?

Solution

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])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top