使用ROC的rfe-svm中{:任务1失败 - “参数长度为零”出错

时间:2017-12-02 01:32:36

标签: svm r-caret roc liblinear rfe

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失败 - “参数长度为零”

请注意,如果我不添加插入,我将收到不同的错误(忽略虚线之间的内容): {:task 1 failed - “undefined columns selected”出错

更新 我打印了堆栈跟踪并得到了此错误,错误与最后一行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"

任何人都可以尝试解释发生了什么吗?

0 个答案:

没有答案