mlr_pipeops_reweighing | R Documentation |
Adjusts class balance and protected group balance in order to achieve fair(er) outcomes.
R6Class object inheriting from PipeOpTaskPreproc
/PipeOp
.
Adds a class weight column to the Task that different Learner
s
may be using. In case initial weights are present, those are multiplied with new weights.
Caution: Only fairness tasks are supported. Which means tasks need to have protected field.
tsk$col_roles$pta
.
Oversamples a Task for more balanced ratios in subgroups and protected groups.
Can be used if a learner does not support weights.
Caution: Only fairness tasks are supported. Which means tasks need to have protected field.
tsk$col_roles$pta
.
PipeOpReweighing*$new(id = "reweighing", param_vals = list())
id
(character(1)
).
param_vals
(list()
)
Input and output channels are inherited from PipeOpTaskPreproc. Instead of a Task
, 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.
The $state
is a named list
with the $state
elements inherited from PipeOpTaskPreproc.
alpha
(numeric()
): A number between 0 (no debiasing) and 1 (full debiasing).
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 reweighing.WEIGHTS
; there will be a naming conflict if this
column already exists and is not a weight column itself.
Only fields inherited from PipeOpTaskPreproc/PipeOp
.
Methods inherited from PipeOpTaskPreproc/PipeOp
.
mlr3pipelines::PipeOp
-> mlr3pipelines::PipeOpTaskPreproc
-> PipeOpReweighingWeights
new()
Creates a new instance of this [R6][R6::R6Class][PipeOp] R6 class.
PipeOpReweighingWeights$new(id = "reweighing_wts", param_vals = list())
id
character
The PipeOps identifier in the PipeOps library.
param_vals
list
The parameter values to be set.
alpha: controls the proportion between initial weight (1 if non existing) and reweighing weight. Defaults to 1. Here is how it works: new_weight = (1 - alpha) * 1 + alpha x reweighing_weight final_weight = old_weight * new_weight
clone()
The objects of this class are cloneable with this method.
PipeOpReweighingWeights$clone(deep = FALSE)
deep
Whether to make a deep clone.
mlr3pipelines::PipeOp
-> mlr3pipelines::PipeOpTaskPreproc
-> PipeOpReweighingOversampling
new()
PipeOpReweighingOversampling$new(id = "reweighing_os", param_vals = list())
id
‘character’
The PipeOp's id.
param_vals
‘list’
A list of parameter values.
clone()
The objects of this class are cloneable with this method.
PipeOpReweighingOversampling$clone(deep = FALSE)
deep
Whether to make a deep clone.
Kamiran, Faisal, Calders, Toon (2012). “Data preprocessing techniques for classification without discrimination.” Knowledge and Information Systems, 33(1), 1–33.
https://mlr3book.mlr-org.com/list-pipeops.html
Other PipeOps:
mlr_pipeops_equalized_odds
,
mlr_pipeops_explicit_pta
library("mlr3")
library("mlr3pipelines")
reweighing = po("reweighing_wts")
learner_po = po("learner", learner = lrn("classif.rpart"))
data = tsk("adult_train")
graph = reweighing %>>% learner_po
glrn = GraphLearner$new(graph)
glrn$train(data)
tem = glrn$predict(data)
tem$confusion
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.