library(LiblineaR)
library(kernlab)
library(caret)
packageVersion('caret')
library(doMC)
registerDoMC(cores=4)
# load dataset
iris <- iris[1:100,]
iris$Species <- as.factor(as.character(iris$Species))
# set parameters
crsvalidation<-2
subsetsize<-2
cost<-c(2^-20)
rfe.grid<-expand.grid(cost=cost, weight=c(1.571, 0.6367), Loss="hinge loss")
# use ROC measure
caretFuncs$summary<-twoClassSummary
# define parameters for recursive feature elimiation
rfeCtrl = rfeControl(functions=caretFuncs,
number=crsvalidation, method="cv", verbose=T, rerank=T,
saveDetails=T, allowParallel=T)
# define parameters for training
tCtrl = trainControl(classProbs = TRUE,summaryFunction = twoClassSummary, allowParallel = T)
# run model
rfe(iris[,-5], iris[,5], sizes = subsetsize,
rfeControl=rfeCtrl,
#pass option to train()
trainControl=tCtrl, metric="ROC",
maximize=T,method="svmLinearWeights2",
tuneGrid=rfe.grid, scale=T, preProc=NULL)
我插入的所有打印件均已成功打印,但出现错误:{ 中的错误:任务 1 失败 - “参数长度为零”
请注意,如果我不添加插入,我会得到一个不同的错误(运行忽略虚线之间的内容):{中的错误:任务 1 失败 - “选择了未定义的列”
更新
我打印了堆栈跟踪并收到此错误,该错误与最后一行相关联rfe(iris[,-5], iris[,5], sizes = subsetsize...)
:
at stop(simpleError(msg, call = expr))
at e$fun(obj, substitute(ex), parent.frame(), e$data)
at foreach(iter = seq(along = resampleIndex), .combine = "c", .verbose = FALSE
at nominalRfeWorkflow(x, y, sizes, ppOpts = NULL, ctrl = rfeControl, lev = cla
at rfe.default(iris[, -5], iris[, 5], sizes = subsetsize, rfeControl = rfeCtrl
at rfe(iris[, -5], iris[, 5], sizes = subsetsize, rfeControl = rfeCtrl, trainC
at #3: assign(paste0("aa.m.train.rfe.", i, sep = ""), rfe(iris[, -5], iris[, 5
at withVisible(expr)
at #41: withCallingHandlers(withVisible(expr), debug = logger, message = logge
at withJavaLogging({
for (i in cost) {
rfe.grid <- expand.grid(cos
Error in { : task 1 failed - "undefined columns selected"
任何人都可以尝试解释发生了什么吗?