class fairlearn.reductions.TruePositiveRateParity(*, difference_bound=None, ratio_bound=None, ratio_bound_slack=0.0)[source]#

Implementation of true positive rate parity as a moment.


The true positive rate parity fairness criterion is also known as “equal opportunity”.

Adds conditioning on label Y=1 compared to demographic parity, i.e.,

\[P[h(X) = 1 | A = a, Y = 1] = P[h(X) = 1 | Y = 1] \; \forall a\]

This implementation of UtilityParity defines the event corresponding to Y=1.

The prob_event pandas.DataFrame will record the fraction of the samples corresponding to Y = 1 in the Y array.

The index MultiIndex will have a number of entries equal to the number of unique values of the sensitive feature, multiplied by the number of unique non-NaN values of the constructed event array, whose entries are either NaN or label=1 (so only one unique non-NaN value), multiplied by two (for the Lagrange multipliers for positive and negative constraints).

With these definitions, the UtilityParity.signed_weights() method will calculate the costs for Y=1 as they are calculated in Example 4 of Agarwal et al.1, but will use the weights equal to zero for Y=0.

This Moment also supports control features, which can be used to stratify the data, with the constraint applied within each stratum, but not between strata.

Read more in the User Guide.


Return the number of samples in the data.



Return bound vector.


Return the default objective for moments of this kind.


Calculate the degree to which constraints are currently violated by the predictor.

load_data(X, y, *, sensitive_features[, ...])

Load the specified data into the object.


Return the projected lambda values.


Compute the signed weights.