我正在使用包中的rfe
功能caret
进行功能选择。我经常收到以下错误:
'{中的错误:任务1失败-“在为函数'as.data.frame'选择方法时评估参数'x'时出错:
[.data.frame
(x,,保留,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
?