holisticai.bias.metrics.statistical_parity_regression#

holisticai.bias.metrics.statistical_parity_regression(group_a, group_b, y_pred, q=0.5)[source]#

Statistical Parity quantile (Regression version)

This function computes the difference of success rates between group_a and group_b, where sucess means that the predicted score exceeds a given quantile.

If q is a vector, this function returns a vector with the respective result for each given quantile in q.

Interpretation

A value of 0 is desired. Values below 0 are unfair towards group_a. Values above 0 are unfair towards group_b.

Parameters

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

y_predarray-like

Predictions vector (regression)

qfloat, array-like, optional

quantile of predictions considered, default=0.5

Returns

float

Statistical Parity (top %) : SR_a - SR_b

Examples

>>> import numpy as np
>>> from holisticai.bias.metrics import statistical_parity_regression
>>> group_a = np.array([1, 1, 1, 1, 0, 0, 0, 0, 0, 0])
>>> group_b = np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1])
>>> y_pred = np.array([0.8, 0.9, 0.2, 0.1, 0.7, 0.9, 0.8, 0.6, 0.3, 0.5])
>>> statistical_parity_regression(group_a, group_b, y_pred, q=0.7)
0.16666666666666669