我正在使用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
?