如何从插入符号 GA 中获得最佳功能?

How get the best features from caret GA?

我开始使用 CARET GA 功能选择

我如何获得 final/best 选定的特征?

我想像这样使用:

gbmFit1 <- train(Class ~ [best feature here], data = training,
                 method = "gbm",
                 trControl = fitControl,
                 verbose = FALSE)

代码如下:

    ga_ctrl <- gafsControl(functions = rfGA,
                       method = "repeatedcv",
                       repeats = 5)

## Use the same random number seed as the RFE process
## so that the same CV folds are used for the external
## resampling. 
set.seed(10)
rf_ga <- gafs(x = x, y = y,
              iters = 200,
              gafsControl = ga_ctrl)
rf_ga

基本上,

你只需要调用这个变量:

rf_ga$optVariables

bestFeatures <- rf_ga$ga$final

并将return 最佳 选定功能。