holisticai.bias.metrics.disparate_impact_regression#
- holisticai.bias.metrics.disparate_impact_regression(group_a, group_b, y_pred, q=0.8)[source]#
Disparate Impact quantile (Regression version)
This function computes the ratio of success rates between group_a and group_b, where sucess means predicted score exceeds a given quantile (default = 0.8).
If q is a vector, this function returns a vector with the respective result for each given quantile in q.
Interpretation
A value of 1 is desired. Values below 1 are unfair towards group_a. Values above 1 are unfair towards group_b. The range (0.8,1.2) is considered acceptable.
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.8
Returns
- float
Disparate Impact (top %)
Notes
\(\frac{sr_a}{sr_b}\)
Examples
>>> import numpy as np >>> from holisticai.bias.metrics import disparate_impact_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]) >>> disparate_impact_regression(group_a, group_b, y_pred, q=0.7) 1.5