R: Fuse learner with a feature filter method.

makeFilterWrapper {mlr} | R Documentation

## Fuse learner with a feature filter method.

### Description

Fuses a base learner with a filter method. Creates a learner object, which can be used like any other learner object. Internally uses filterFeatures before every model fit.

After training, the selected features can be retrieved with getFilteredFeatures.

Note that observation weights do not influence the filtering and are simply passed down to the next learner.

### Usage

    makeFilterWrapper(learner, fw.method = "randomForestSRC.rfsrc",
      fw.perc = NULL, fw.abs = NULL, fw.threshold = NULL,
      fw.mandatory.feat = NULL, ...)

### Arguments

`learner` | (Learner | `character(1)`) The learner. If you pass a string the learner will be created via makeLearner.
`fw.method` | (`character(1)`) Filter method. See listFilterMethods. Default is “randomForestSRC.rfsrc”.
`fw.perc` | (`numeric(1)`) If set, select `fw.perc`*100 top scoring features. Mutually exclusive with arguments `fw.abs` and `fw.threshold`.
`fw.abs` | (`numeric(1)`) If set, select `fw.abs` top scoring features. Mutually exclusive with arguments `fw.perc` and `fw.threshold`.
`fw.threshold` | (`numeric(1)`) If set, select features whose score exceeds `fw.threshold`. Mutually exclusive with arguments `fw.perc` and `fw.abs`.
`fw.mandatory.feat` | (character) Mandatory features which are always included regardless of their scores
`...` | (any) Additional parameters passed down to the filter.

### Value

Learner.

### See Also

Other filter: `filterFeatures`, `generateFilterValuesData`, `getFilterValues`, `getFilteredFeatures`, `listFilterMethods`, `makeFilter`, `plotFilterValues`

Other wrapper: `makeBaggingWrapper`, `makeClassificationViaRegressionWrapper`, `makeConstantClassWrapper`, `makeCostSensClassifWrapper`, `makeCostSensRegrWrapper`, `makeDownsampleWrapper`, `makeDummyFeaturesWrapper`, `makeExtractFDAFeatsWrapper`, `makeFeatSelWrapper`, `makeImputeWrapper`, `makeMulticlassWrapper`, `makeMultilabelBinaryRelevanceWrapper`, `makeMultilabelClassifierChainsWrapper`, `makeMultilabelDBRWrapper`, `makeMultilabelNestedStackingWrapper`, `makeMultilabelStackingWrapper`, `makeOverBaggingWrapper`, `makePreprocWrapperCaret`, `makePreprocWrapper`, `makeRemoveConstantFeaturesWrapper`, `makeSMOTEWrapper`, `makeTuneWrapper`, `makeUndersampleWrapper`, `makeWeightedClassesWrapper`

### Examples

    task = makeClassifTask(data = iris, target = "Species")
    lrn = makeLearner("classif.lda")
    inner = makeResampleDesc("Holdout")
    outer = makeResampleDesc("CV", iters = 2)
    lrn = makeFilterWrapper(lrn, fw.perc = 0.5)
    mod = train(lrn, task)
    print(getFilteredFeatures(mod))
    # now nested resampling, where we extract the features that the filter method selected
    r = resample(lrn, task, outer, extract = function(model) {
      getFilteredFeatures(model)
    })
    print(r$extract)

[Package mlr version 2.13 Index]