Filtor that wraps two other Filtors given during construction and chooses which operation to perform. Each of the resulting n_filter individuals is chosen either from $filtor, or from $filtor_not.

This makes it possible to implement filter methods such as random interleaving, where only a fraction of p individuals were filtered and the others were not.

Letting the number of individuals chosen by $filtor be n_filter_f, then n_filter_f is either fixed set to round(n_filter * p), (when random_choise is FALSE) or to rbinom(1, n_filter, p) (when random_choice is TRUE).

When random_choice is FALSE, then $needed_input() is calculated directly from $needed_input() of $filtor and $filtor_not, as well as n_filter_f and n_filter - n_filter_f.

When random_choice is TRUE, then $needed_input() is considers the "worst case" from $filtor and $filtor_not, and assumes that $needed_input() is monotonically increasing in its input argument.

To make the worst case less extreme, the number of individuals chosen with random_choice set to TRUE is limited to qbinom(-20, n_filter, p, log.p = TRUE) (with lower.tail FALSE and TRUE for $filtor and $filtor_not, respectively), which distorts the binomial distribution with probability 1 - exp(-20) or about 1 - 0.5e-9.

Configuration Parameters

This operator has the configuration parameters of the Filtors that it wraps: The configuration parameters of the operator given to the filtor construction argument are prefixed with "maybe.", the configuration parameters of the operator given to the filtor_not construction argument are prefixed with "maybe_not.".

Additional configuration parameters:

  • p :: numeric(1)
    Probability per individual (when random_choise is TRUE), or fraction of individuals (when random_choice is FALSE), that are chosen from $filtor instead of $filtor_not. Must be set by the user.

  • random_choice :: logical(1)
    Whether to sample the number of individuals chosen by $filtor according to rbinom(1, n_filter, p), or to use a fixed fraction. Initialized to FALSE.

Supported Operand Types

Supported Param classes are the set intersection of supported classes of filtor and filtor_not.

Dictionary

This Filtor can be created with the short access form ftr() (ftrs() to get a list), or through the the dictionary dict_filtors in the following way:

# preferred:
ftr("maybe", <filtor> [, <filtor_not>])
ftrs("maybe", <filtor> [, <filtor_not>])  # takes vector IDs, returns list of Filtors

# long form:
dict_filtors$get("maybe", <filtor> [, <filtor_not>])

Super classes

miesmuschel::MiesOperator -> miesmuschel::Filtor -> FiltorMaybe

Active bindings

filtor

(Filtor)
Filtor being wrapped. This operator gets run with probability / proportion p (configuration parameter).

filtor_not

(Filtor)
Alternative Filtor being wrapped. This operator gets run with probability / proportion 1 - p (configuration parameter).

Methods

Inherited methods


Method new()

Initialize the FiltorMaybe object.

Usage

FiltorMaybe$new(filtor, filtor_not = FiltorNull$new())

Arguments

filtor

(Filtor)
Filtor to wrap. This operator gets run with probability p (Configuration parameter).
The constructed object gets a clone of this argument. The $filtor field will reflect this value.

filtor_not

(Filtor)
Another Filtor to wrap. This operator runs when filtor is not chosen. By default, this is FiltorNull, i.e. no filtering. With this default, the FiltorMaybe object applies the filtor operation with probability / proportion p, and no operation at all otherwise.
The constructed object gets a clone of this argument. The $filtor_not field will reflect this value.


Method prime()

See MiesOperator method. Primes both this operator, as well as the wrapped operators given to filtor and filtor_not during construction.

Usage

FiltorMaybe$prime(param_set)

Arguments

param_set

(ParamSet)
Passed to MiesOperator$prime().

Returns

invisible self.


Method clone()

The objects of this class are cloneable with this method.

Usage

FiltorMaybe$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library("mlr3")
library("mlr3learners")

fm = ftr("maybe", ftr("surprog", lrn("regr.lm"), filter.pool_factor = 2), p = 0.5)
p = ps(x = p_dbl(-5, 5))
known_data = data.frame(x = 1:5)
fitnesses = 1:5
new_data = data.frame(x = c(0.5, 1.5, 2.5, 3.5, 4.5))

fm$prime(p)

fm$needed_input(2)
#> [1] 3

fm$operate(new_data, known_data, fitnesses, 2)
#> [1] 2 3

fm$param_set$values$p = 0.33

fm$needed_input(3)
#> [1] 4

fm$operate(new_data, known_data, fitnesses, 3)
#> [1] 2 3 4