我正在学习如何使用kernlab中的ksvm进行分类。我玩了一些例子(即虹膜等)。但是,当我尝试使用我的数据时,我不断收到错误:
rbfdot中的错误(长度= 4,lambda = 0.5): 未使用的参数(长度= 4,lambda = 0.5)
如果有人能够指出出了什么问题,或者请指出适当的文件,我真的很感激。
附件是我的数据文件。
DataFile:http://www.mediafire.com/view/?todfg2su1qmw18n
我的R代码:
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)
答案 0 :(得分:2)
查看rbfdot
的文档,该函数没有输入参数length
也没有lambda
,这正是错误消息所说的。内核函数stringdot
确实有这些参数,但没有sigma
参数。要生成内核,请仔细查看at the documentation。