This measure allows constructing for 'constraint' measures of the following form:
$$min performance subject to fairness < \epsilon$$
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.
Super class
mlr3::Measure
-> MeasureFairnessConstraint
Methods
Method new()
Creates a new instance of this R6 class.
Usage
MeasureFairnessConstraint$new(
id = NULL,
performance_measure,
fairness_measure,
epsilon = 0.01,
range = c(-Inf, Inf)
)
Arguments
id
(
character
)
The measure's id. Set to 'fairness.<base_measure_id>' if ommited.performance_measure
(
Measure()
)
The measure used to measure performance (e.g. accuracy).fairness_measure
(
Measure()
)
The measure used to measure fairness (e.g. equalized odds).epsilon
(
numeric
)
Allowed divergence from perfect fairness. Initialized to 0.01.range
(
numeric
)
Range of the resulting measure. Defaults toc(-Inf, Inf)
.
Examples
# Accuracy subject to equalized odds fairness constraint:
library("mlr3")
t = tsk("adult_train")
learner = lrn("classif.rpart", cp = .01)
learner$train(t)
measure = msr("fairness.constraint", id = "acc_tpr", msr("classif.acc"), msr("fairness.tpr"))
predictions = learner$predict(t)
predictions$score(measure, task = t)
#> acc_tpr
#> -0.05976471