使用mlr进行递归特征消除

问题描述 投票:0回答:1

可以用mlr进行递归特征消除功能(rfe)吗?我知道这可以用插入符号here,但即使有一些关于使用mlr进行特征选择的文档,我也没有找到与rfe等效的文件。

r r-caret mlr
1个回答
5
投票

要在mlr中执行递归特征消除,您可以使用函数makeFeatSelControlSequential和参数method = sbs(顺序向后选择)。以下是使用lda学习器的使用示例:

library(mlr)
ctrl <- makeFeatSelControlSequential(method = "sbs",
                                     beta = 0.005)

rdesc <- makeResampleDesc("CV", iters = 3)

sfeats <- selectFeatures(learner = "classif.lda",
                         task = sonar.task,
                         resampling = rdesc,
                         control = ctrl,
                         show.info = FALSE)


FeatSel result:
Features (57): V1, V2, V3, V4, V5, V6, V7, V8, V9, V11, V12, V13, V14, V15, V16, V17, V18, V19, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36, V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54, V55, V56, V57, V58, V60
mmce.test.mean=0.2066943

在这里,选择了60个中的57个变量。

您可以使用:

analyzeFeatSelResult(sfeats)

掌握选择路径

#output
    Path to optimum:
- Features:   60  Init   :                       Perf = 0.26936  Diff: NA  *
- Features:   59  Remove : V59                   Perf = 0.2403  Diff: 0.029055  *
- Features:   58  Remove : V10                   Perf = 0.22588  Diff: 0.014424  *
- Features:   57  Remove : V20                   Perf = 0.20669  Diff: 0.019186  *

Stopped, because no improving feature was found.
© www.soinside.com 2019 - 2024. All rights reserved.