holisticai.bias.metrics.zscore_diff#
- holisticai.bias.metrics.zscore_diff(group_a, group_b, y_pred, q=0)[source]#
ZScore Difference
This function computes the spread in Zscores between group_a and group_b. The Zscore is a normalised version of Disparate Impact.
If q is a vector, this function returns a vector with the respective result for each given quantile in q.
A value of 0 is desired. The Zscore will approximate the number of standard deviations away from the mean. In particular values that exceed 2 are statistically significant with 95% probability.
- 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.
- float
ZScore Difference
:math:`
rac{ exttt{AVgroup_a} - exttt{AVgroup_b}}{ exttt{STD_pool}}`
>>> import numpy as np >>> from holisticai.bias.metrics import zscore_diff >>> 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.2, 0.9, 0.3, 0.6, 0.3, 0.5]) >>> zscore_diff(group_a, group_b, y_pred) 0.1166919931983158