Allows for calculation of arbitrary mlr3::Measure()
s on a selected sub-group.
Super class
mlr3::Measure
-> MeasureSubgroup
Public fields
base_measure
(
Measure()
)
The base measure to be used by the fairness measures, e.g. mlr_measures_classif.fpr for the false positive rate.subgroup
(
character
)|(integer
)
Subgroup identifier.intersect
(
logical
)
Should groups be intersected?
Methods
Method new()
Creates a new instance of this R6 class.
Usage
MeasureSubgroup$new(id = NULL, base_measure, subgroup, intersect = TRUE)
Arguments
id
(
character
)
The measure's id. Set to 'fairness.<base_measure_id>' if ommited.base_measure
(
Measure()
)
The measure used to measure fairness.subgroup
(
character
)|(integer
)
Subgroup identifier. Either value for the protected attribute or position intask$levels
.intersect
logical
Should multiple pta groups be intersected? Defaults toTRUE
. Only relevant if more than onepta
columns are provided.
Examples
library("mlr3")
# Create MeasureFairness to measure the Predictive Parity.
t = tsk("adult_train")
learner = lrn("classif.rpart", cp = .01)
learner$train(t)
measure = msr("subgroup", base_measure = msr("classif.acc"), subgroup = "Female")
predictions = learner$predict(t)
predictions$score(measure, task = t)
#> subgroup.acc_Female
#> 0.9232628