Adjusts class balance and protected group balance in order to achieve fair(er) outcomes.
R6::R6Class object inheriting from mlr3pipelines::PipeOpTaskPreproc/mlr3pipelines::PipeOp.
Adds a class weight column to the mlr3::Task that different mlr3::Learners
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 mlr3::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 mlr3pipelines::PipeOpTaskPreproc. Instead of a mlr3::Task, a mlr3::TaskClassif is used as input and output during training and prediction.
The output during training is the input mlr3::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 mlr3pipelines::PipeOpTaskPreproc.
alpha (numeric()): A number between 0 (no debiasing) and 1 (full debiasing).
Introduces, or overwrites, the "weights" column in the mlr3::Task. However, the mlr3::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 mlr3pipelines::PipeOpTaskPreproc/mlr3pipelines::PipeOp.
Methods inherited from mlr3pipelines::PipeOpTaskPreproc/mlr3pipelines::PipeOp.
mlr3pipelines::PipeOp -> mlr3pipelines::PipeOpTaskPreproc -> PipeOpReweighingWeights
new()Creates a new instance of this R6::R6Class R6 class.
PipeOpReweighingWeights$new(id = "reweighing_wts", param_vals = list())idcharacter
The PipeOps identifier in the PipeOps library.
param_valslist
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)deepWhether 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)deepWhether 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
Run the code above in your browser using DataLab