holisticai.bias.metrics.cohen_d#
- holisticai.bias.metrics.cohen_d(group_a, group_b, y_pred)[source]#
Cohen D
This function computes the Cohen D statistic (normalised statistical parity) between group_a and group_b.
A value of 0 is desired. Negative values are unfair towards group_a. Positive values are unfair towards group_b. Reference values: 0.2 is considered a small effect size, 0.5 is considered medium, 0.8 is considered large.
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
- y_predarray-like
Predictions vector (binary)
- float
Cohen D :
:math:`
rac{sr_a-sr_b}{ exttt{std_pool}}`
>>> import numpy as np >>> from holisticai.bias.metrics import cohen_d >>> 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, 0, 0, 1, 1, 0, 1, 1, 1]) >>> cohen_d(group_a, group_b, y_pred) -0.7844645405527363