什么原因导致在rfe中选择了未定义的列?

时间:2012-10-09 11:33:54

标签: r

我正在使用rfe包中的caret功能来进行功能选择。我经常收到以下错误:

  {p>错误{:     任务1失败 - “在为函数'as.data.frame'选择方法时评估参数'x'时出错:[.data.frame中的错误(x,,retain,drop = FALSE):     选定未定义的列

我正在做100个样本,它会在产生错误之前运行大约60个样本,我正在执行以下操作:

folds=100
validmethod='boot'
subsets=c(5,10,15,20,25)

ctrl <- rfeControl(functions = funcs,
                   method = validmethod,
                   rerank=TRUE,
                   saveDetails=TRUE,
                   verbose = TRUE,
                   returnResamp = "all",
                   number=folds)

rfe(df.preds,df.depend, metric=smetric,sizes=subsets, rfeControl=ctrl)

有人可以帮我理解导致此错误的事物类型吗?

MWE:

df <- cbind(rbinom(100, 1, 0.5), rnorm(100, 0, 1), 
    rnorm(100, 5, 5), rnorm(100, 12, 4), rnorm(100, 100, 0.1))
colnames(df) <- c("response", "f1", "f2", "f3", "f4")
rfe(x=df[,-1], y=as.factor(df[,1]), sizes = 1:3,
    rfeControl = rfeControl(functions = caretFuncs, 
    number = 2, method = "cv"),method = "svmRadial")

如何选择sizes

0 个答案:

没有答案