holisticai.bias.metrics.statistical_parity#

holisticai.bias.metrics.statistical_parity(group_a, group_b, y_pred)[source]#

Statistical parity.

This function computes the statistical parity (difference of success rates) between group_a and group_b.

Interpretation

A value of 0 is desired. Negative values are unfair towards group_a. Positive values are unfair towards group_b. The range (-0.1,0.1) is considered acceptable.

Parameters

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

y_predarray-like

Predictions vector (binary)

Returns

float

Statistical Parity

Notes

\(sr_a - sr_b\)

Examples

>>> import numpy as np
>>> from holisticai.bias.metrics import statistical_parity
>>> 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([1, 1, 1, 0, 1, 1, 0, 0, 0, 0])
>>> statistical_parity(group_a, group_b, y_pred)
0.4166666666666667