[R] Data format for KSVM

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Oct 24 17:23:25 CEST 2009



Noah Silverman wrote:
> Hi,
> 
> I have a process using svm from the e1071 library. 

It's called a *package* which is probably installed in a *library* of 
packages.


> it works.
> 
> I want to try using the KSVM library instead.  The same data used wiht 
> e1071 gives me an error with KSVM.

I guess you are talking about the ksvm *function* in *package* kernlab 
now, right?


> 
> My data is a data.frame.
> 
> sample code:
> 
> svm_formula <- formula(y ~ a + B + C)


You do not use svm_function below, do you?


> svm_model <- ksvm(formula, data=train_data, type="C-svc", 
> kernel="rbfdot", C=1)
 >
> I get the following error:
> 
> "object is not a matrix"


ksvm works for me. Please specify a reproducible example (including the 
data) or give us at least the output of str(data)  and specofy which 
verions of R and kernlab you are talking about.

Uwe Ligges




> So I tried this:
> 
> svm_model <- ksvm(formula, data=as.matrix(train_data), type="C-svc", 
> kernel="rbfdot", C=1, scaled=FALSE)
> 
> Now I get this error:
> "Error in model.fram.definition(data = list(v1 = c(1.1234, -2.3232:
> Object is not a matrix
> 
> My data was previously scaled with the scale() function so that the mean 
> is centered at 0. and the range is {-1,1}
> 
> Can anyone provide some suggestions as to why I'm getting an error?
> 
> Thanks!
> 
> -N
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list