Adds a class weight column to the
Task that different
Learners may be
able to use for sample weighting. Sample weights are added to each sample according to the target class.
Only binary classification tasks are supported.
Caution: when constructed naively without parameter, the weights are all set to 1. The
must be adjusted for this
PipeOp to be useful.
R6Class object inheriting from
PipeOpClassWeights$new(id = "classweights", param_vals = list())
Identifier of the resulting object, default
param_vals :: named
List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Default
Input and output channels are inherited from
PipeOpTaskPreproc. Instead of a
TaskClassif is used as input and output during training and prediction.
The output during training is the input
Task with added weights column according to target class.
The output during prediction is the unchanged input.
$state is a named
list with the
$state elements inherited from
The parameters are the parameters inherited from
PipeOpTaskPreproc; however, the
affect_columns parameter is not present. Further parameters are:
Weight given to samples of the minor class. Major class samples have weight 1. Initialized to 1.
Introduces, or overwrites, the "weights" column in the
Task. However, the
Learner method needs to
respect weights for this to have an effect.
The newly introduced column is named
.WEIGHTS; there will be a naming conflict if this column already exists and is not a
weight column itself.
Only fields inherited from
Only methods inherited from
library("mlr3") task = tsk("spam") opb = po("classweights") # task weights task$weights # double the instances in the minority class (spam) opb$param_set$values$minor_weight = 2 result = opb$train(list(task))[[1L]] result$weights
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.