Skip to contents

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

Inherited 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 in task$levels.

intersect

logical
Should multiple pta groups be intersected? Defaults to TRUE. Only relevant if more than one pta columns are provided.


Method clone()

The objects of this class are cloneable with this method.

Usage

MeasureSubgroup$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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