| dict_filtors_maybe {miesmuschel} | R Documentation |
Filtor-Combination that Filters According to Two Filtors
Description
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 (whenrandom_choiseisTRUE), or fraction of individuals (whenrandom_choiceisFALSE), that are chosen from$filtorinstead of$filtor_not. Must be set by the user. -
random_choice::logical(1)
Whether to sample the number of individuals chosen by$filtoraccording torbinom(1, n_filter, p), or to use a fixed fraction. Initialized toFALSE.
Supported Operand Types
Supported Domain 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
Methods
Public methods
Inherited methods
Method new()
Initialize the FiltorMaybe object.
Usage
FiltorMaybe$new(filtor, filtor_not = FiltorNull$new())
Arguments
filtor(
Filtor)
Filtorto wrap. This operator gets run with probabilityp(Configuration parameter).
The constructed object gets a clone of this argument. The$filtorfield will reflect this value.filtor_not(
Filtor)
AnotherFiltorto wrap. This operator runs whenfiltoris not chosen. By default, this isFiltorNull, i.e. no filtering. With this default, theFiltorMaybeobject applies thefiltoroperation with probability / proportionp, and no operation at all otherwise.
The constructed object gets a clone of this argument. The$filtor_notfield 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 toMiesOperator$prime().
Returns
invisible self.
Method clone()
The objects of this class are cloneable with this method.
Usage
FiltorMaybe$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other filtors:
Filtor,
FiltorSurrogate,
dict_filtors_null,
dict_filtors_proxy,
dict_filtors_surprog,
dict_filtors_surtour
Other filtor wrappers:
dict_filtors_proxy
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)
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)