0

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)
FX_Ng
  • 1
  • 1
  • 2

1 Answers1

2

Looking at the documentation of rbfdot, the function does not have the input arguments length nor lambda, which is exactly what the error message says. The kernel function stringdot does have these arguments, but does not have the sigma argument. For generating kernels, take a more close look at the documentation.

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
  • Thanks for the answer. I just realized that the code for input argument for length and lambda was there. If you remove it, or change the kernel function, the problem is still there. I guess now the problem is more about the format of the data (matrix vs. non matrix), but not because of the kernel function. I'm still figuring how to make it work. – FX_Ng Oct 08 '12 at 05:38
  • If you want more help, please update your question above, or write a new question. – Paul Hiemstra Oct 08 '12 at 05:52
  • Thanks. Problem resolved. As I said, there problem was still about the unused argument regardless of using rbf kernel or other kernels. I figured out that it's all because of the format xtrain and ytrain. Anyway, thanks for the guidance. – FX_Ng Oct 08 '12 at 15:34