fairness_tensor {mlr3fairness}R Documentation

Compute the Fairness Tensor given a Prediction and a Task

Description

A fairness tensor is a list of groupwise confusion matrices.

Usage

fairness_tensor(object, normalize = "all", ...)

## S3 method for class 'data.table'
fairness_tensor(object, normalize = "all", task, ...)

## S3 method for class 'PredictionClassif'
fairness_tensor(object, normalize = "all", task, ...)

## S3 method for class 'ResampleResult'
fairness_tensor(object, normalize = "all", ...)

Arguments

object

(data.table() | PredictionClassif | ResampleResult)
A data.table with columns truth and prediction, a PredictionClassif or a ResampleResult.

normalize

(character)
How should the fairness tensor be normalized? "all" normalizes entries by dividing by dataset size, "group" normalizes entries by dividing by group size and "none" does not conduct any normalization at all.

...

any
Currently not used.

task

(TaskClassif)
A TaskClassif. Needs col_role "pta" to be set.

Value

list() of confusion matrix for every group in "pta".

Protected Attributes

The protected attribute is specified as a col_role in the corresponding Task():
⁠<Task>$col_roles$pta = "name_of_attribute"⁠
This also allows specifying more than one protected attribute, in which case fairness will be considered on the level of intersecting groups defined by all columns selected as a predicted attribute.

Examples

library("mlr3")
task = tsk("compas")
prediction = lrn("classif.rpart")$train(task)$predict(task)
fairness_tensor(prediction, task = task)

[Package mlr3fairness version 0.3.2 Index]