holisticai.bias.metrics.mad_score#
- holisticai.bias.metrics.mad_score(group_a, group_b, mat_pred, normalize=False)[source]#
Mean Absolute Deviation
Difference in average score for group_a and group_b.
Interpretation
A large value of MAD indicates differential treatment ofgroup a and group b. A positive value indicates thatgroup a received higher scores on average, whilea negative value indicates higher ratings for group b.
Parameters
- group_aarray-like
Group membership vector.
- group_barray-like
Group membership vector.
- mat_predmatrix-like
Matrix with shape (num_users, num_items). A recommender score (binary or soft pred) for each user,item interaction.
- normalizebool, optional
If True, normalises the data matrix to [0,1] range.
Returns
- float
MAD Score
Notes
\(\texttt{avg_group_a - avg_group_b}\)
References
Examples
>>> import numpy as np >>> from holisticai.bias.metrics import mad_score >>> 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]) >>> mat_pred = np.array([[0.9, 0.8, 0.4, 0.2], [0.7, 0.9, 0.1, 0.7], [0.3, 0.2, 0.3, 0.3], [0.2, 0.1, 0.7, 0.8], [0.8, 0.7, 0.9, 0.1], [1. , 0.9, 0.3, 0.6], [0.8, 0.9, 0.1, 0.1], [0.2, 0.3, 0.1, 0.5], [0.1, 0.2, 0.7, 0.7], [0.2, 0.7, 0.1, 0.2]]) >>> mad_score(group_a, group_b, mat_pred, normalize=False) 0.00833333333333336