jitendra
jitendra

Reputation: 1458

Issue with R-Kernlab SVM Predict

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

Upvotes: 3

Views: 2264

Answers (1)

John Colby
John Colby

Reputation: 22588

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

Upvotes: 7

Related Questions