我正在学习如何使用 kernlab 的 ksvm 进行分类。我玩过一些例子(即虹膜等)。但是,当我尝试使用我的数据时,我不断收到错误消息:
rbfdot 中的错误(长度 = 4,lambda = 0.5):未使用的参数(长度 = 4,lambda = 0.5)
如果有人能指出出了什么问题,或者向我指出适当的文件,我真的很感激。
附件是我的数据文件。
数据文件: 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)