I'm learning how to use ksvm from kernlab to do classification. I've played with some examples (i.e. iris etc). However, when I try with my data, I keep getting an error:
Error in rbfdot(length = 4, lambda = 0.5) : unused argument(s) (length = 4, lambda = 0.5)
I really appreciate if someone can point out what went wrong, or point me to the appropriate documents.
Attached is my data file.
DataFile: http://www.mediafire.com/view/?todfg2su1qmw18n
My R code:
id = "100397.txt"
dat <- read.table(id, header=FALSE,sep = ",")
n = nrow(dat) # number of data points
numCol = ncol(dat)
dat <- dat[,-c(numCol)] ### get rid of the last column because it is not useful.
numCol = ncol(dat) ### update the number of columns
ntrain <- round(n*0.8) # get 80% of data points for cross-validation training
tindex <- sample(n,ntrain) # get all indices for cross-valication trainining
xtrain <- dat[tindex,-c(numCol)] # training data, not include the class label
xtest <- dat[-tindex,-c(numCol)] # test data, not include the class label
ytrain <- dat[tindex,c(numCol)] # class label for training data
ytest <- dat[-tindex,c(numCol)] # class label for testing data
nrow(xtrain)
length(ytrain)
nrow(xtest)
length(ytest)
### SVM function ###
svp <- ksvm(xtrain, ytrain, type="C-bsvc", kernel='rbf', C = 10, prob.model=TRUE)
Looking at the documentation of
rbfdot
, the function does not have the input argumentslength
norlambda
, which is exactly what the error message says. The kernel functionstringdot
does have these arguments, but does not have thesigma
argument. For generating kernels, take a more close look at the documentation.