mlr_pipeops_reweighing {mlr3fairness}R Documentation

Reweighing to balance disparate impact metric

Description

Adjusts class balance and protected group balance in order to achieve fair(er) outcomes.

Format

R6Class object inheriting from PipeOpTaskPreproc/PipeOp.

PipeOpReweighingWeights

Adds a class weight column to the Task that different 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.

PipeOpReweighingOversampling

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.

Construction

PipeOpReweighing*$new(id = "reweighing", param_vals = list())

Input and Output Channels

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.

State

The ⁠$state⁠ is a named list with the ⁠$state⁠ elements inherited from PipeOpTaskPreproc.

Parameters

Internals

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.

Fields

Only fields inherited from PipeOpTaskPreproc/PipeOp.

Methods

Methods inherited from PipeOpTaskPreproc/PipeOp.

Super classes

mlr3pipelines::PipeOp -> mlr3pipelines::PipeOpTaskPreproc -> PipeOpReweighingWeights

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this [R6][R6::R6Class][PipeOp] R6 class.

Usage
PipeOpReweighingWeights$new(id = "reweighing_wts", param_vals = list())
Arguments
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


Method clone()

The objects of this class are cloneable with this method.

Usage
PipeOpReweighingWeights$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Super classes

mlr3pipelines::PipeOp -> mlr3pipelines::PipeOpTaskPreproc -> PipeOpReweighingOversampling

Methods

Public methods

Inherited methods

Method new()

Usage
PipeOpReweighingOversampling$new(id = "reweighing_os", param_vals = list())
Arguments
id

‘character’
The PipeOp's id.

param_vals

‘list’
A list of parameter values.


Method clone()

The objects of this class are cloneable with this method.

Usage
PipeOpReweighingOversampling$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

Kamiran, Faisal, Calders, Toon (2012). “Data preprocessing techniques for classification without discrimination.” Knowledge and Information Systems, 33(1), 1–33.

See Also

https://mlr3book.mlr-org.com/list-pipeops.html

Other PipeOps: mlr_pipeops_equalized_odds, mlr_pipeops_explicit_pta

Examples

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

[Package mlr3fairness version 0.3.2 Index]