[R] About stringdot (ksvm)

Masanori Higashihara
Tue, 23 May 2006 12:20:06 -0000

Hello R Helpers

I want to use string kernel by ksvm.
Is there an error in my operation?

1)dataset
 test data

 aaa 1
 abb -1
 bbb 1

2)operation
 > library(kernlab)
 > x<-c("aaa","abb","bbb")
 > x
 [1] "aaa" "abb" "bbb"
 > class(x)
 [1] "character"
 > xl<-list(x)
 > y<-c(1,-1,1)
 > y
 [1]  1 -1  1
 > z<-list(x,y)
 > z
 [[1]]
 [1] "aaa" "bab" "bbb"
 [[2]]
 [1]  1 -1  1
 > s.svm<-ksvm(xl,kernel="stringdot",kpar=list(lambda=0.5))
 Error in as.double.default(t(x)) : (list) object cannot be coerced to
'double'
 > s.svm<-ksvm(z,kernel="stringdot",kpar=list(lambda=0.5))
 Error in as.double.default(t(x)) : (list) object cannot be coerced to
'double'

-----------------------------------
Masanori Higashihara,
JAIST: Japan Advanced Institute of Science and Technology.
JAPAN.