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.
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 Domain classes are the set intersection of supported classes of filtor and filtor_not.
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>])
miesmuschel::MiesOperator -> miesmuschel::Filtor -> FiltorMaybe
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).
new()Initialize the FiltorMaybe object.
FiltorMaybe$new(filtor, filtor_not = FiltorNull$new())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.
prime()See MiesOperator method. Primes both this operator, as well as the wrapped operators
given to filtor and filtor_not during construction.
FiltorMaybe$prime(param_set)param_set(ParamSet)
Passed to MiesOperator$prime().
invisible self.
clone()The objects of this class are cloneable with this method.
FiltorMaybe$clone(deep = FALSE)deepWhether to make a deep clone.
Other filtors:
Filtor,
FiltorSurrogate,
dict_filtors_null,
dict_filtors_proxy,
dict_filtors_surprog,
dict_filtors_surtour
Other filtor wrappers:
dict_filtors_proxy
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 = as.numeric(1:5))
fitnesses = as.numeric(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)
fm$operate(new_data, known_data, fitnesses, 2)
fm$param_set$values$p = 0.33
fm$needed_input(3)
fm$operate(new_data, known_data, fitnesses, 3)
Run the code above in your browser using DataLab