R 使用插入符号消除递归特征时出错
我试图使用插入符号进行变量选择,但在某些类型的模型中,我在同一点上遇到了一个错误。我在下面重现了一个错误:{:任务1失败中的错误-下标超出范围”,但我还使用其他数据获取了“任务1失败中的错误-{:任务1失败-”替换有XXX行,数据有YYY“” 我对解决这个特殊的错误感兴趣,并对如何调试这个问题提出建议。谢谢R 使用插入符号消除递归特征时出错,r,machine-learning,R,Machine Learning,我试图使用插入符号进行变量选择,但在某些类型的模型中,我在同一点上遇到了一个错误。我在下面重现了一个错误:{:任务1失败中的错误-下标超出范围”,但我还使用其他数据获取了“任务1失败中的错误-{:任务1失败-”替换有XXX行,数据有YYY“” 我对解决这个特殊的错误感兴趣,并对如何调试这个问题提出建议。谢谢 library(caret) data(iris) predictors <- names(iris)[names(iris)!="Species"] split <- cr
library(caret)
data(iris)
predictors <- names(iris)[names(iris)!="Species"]
split <- createDataPartition(iris$Species, p = .8, list = FALSE)
irisData <- iris[,predictors]
irisData$Class <- iris$Species
training <- irisData[ split, ]
testing <- irisData[-split, ]
times <- 1
folds <- 5
prednumSeq <- seq(1, length(predictors)-1, by = 1)
ctrl <- rfeControl(method = "repeatedcv",
timingSamps = 2,
number = folds,
repeats = times,
saveDetails = TRUE,
verbose = TRUE,
allowParallel = FALSE)
rfRFE <- rfe(training[,predictors],
training$Class,
sizes = prednumSeq,
rfeControl = ctrl)
sessionInfo()中的详细信息包括:
尝试options(error=recover)
并查看是否可以发现有问题的行。
+(rfe) fit Fold1.Rep1 size: 4
-(rfe) fit Fold1.Rep1 size: 4
+(rfe) imp Fold1.Rep1
+(rfe) fit Fold2.Rep1 size: 4
-(rfe) fit Fold2.Rep1 size: 4
+(rfe) imp Fold2.Rep1
+(rfe) fit Fold3.Rep1 size: 4
-(rfe) fit Fold3.Rep1 size: 4
+(rfe) imp Fold3.Rep1
+(rfe) fit Fold4.Rep1 size: 4
-(rfe) fit Fold4.Rep1 size: 4
+(rfe) imp Fold4.Rep1
+(rfe) fit Fold5.Rep1 size: 4
-(rfe) fit Fold5.Rep1 size: 4
+(rfe) imp Fold5.Rep1
Error in { : task 1 failed - "subscript out of bounds"
R version 3.0.0 (2013-04-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MASS_7.3-26 randomForest_4.6-7 e1071_1.6-1 class_7.3-7
[5] pROC_1.5.4 caret_5.15-61 reshape2_1.2.2 plyr_1.8
[9] lattice_0.20-15 foreach_1.4.0 cluster_1.14.4
loaded via a namespace (and not attached):
[1] codetools_0.2-8 compiler_3.0.0 grid_3.0.0 iterators_1.0.6 stringr_0.6.2
[6] tools_3.0.0