我正在尝试使用 caret 包实现我的自定义功能以进行功能排名。问题是每次第一次调用摘要函数时,我只得到 10 个条目。这在这里不是问题,但在一个更大的数据集中,一个类只是所有条目的一小部分(比如 5%),它可能根本不会被选中
l = lmFuncs
l$summary = function (data, lev = NULL, model = NULL)
{
print(dim(data))
if (is.character(data$obs))
data$obs <- factor(data$obs, levels = lev)
postResample(data[, "pred"], data[, "obs"])
}
rfe(data.frame(matrix(rnorm(100*3), ncol=3)), sample(2, 100, replace=T), sizes=1:3, rfeControl=rfeControl(functions=l, number=20))
输出:
[1] 10 2
[1] 32 3
[1] 32 3
[1] 32 3
[1] 40 3
[1] 40 3
[1] 40 3
[1] 37 3
[1] 37 3
[1] 37 3
...
R会话信息:
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 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] pROC_1.5.4 kernlab_0.9-14 e1071_1.6-1 class_7.3-5 caret_5.15-044 foreach_1.4.0 cluster_1.14.3 reshape_0.8.4 plyr_1.7.1
[10] lattice_0.20-10 Biobase_2.18.0 BiocGenerics_0.4.0
loaded via a namespace (and not attached):
[1] codetools_0.2-8 compiler_2.15.1 grid_2.15.1 iterators_1.0.6 tools_2.15.1