holisticai.bias.metrics.min_cluster_ratio#
- holisticai.bias.metrics.min_cluster_ratio(group_a, group_b, y_pred)[source]#
Minimum Cluster Ratio
Given a clustering and protected attributes. The min cluster ratio is the minimum over all clusters of the ratio of number of group_a members to the number of group_b members.
Interpretation
A value of 1 is desired. That is when all clusters are perfectly balanced. Low values imply the existence of clusters where group_a has fewer members than group_b.
Parameters
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
- y_predarray-like
Cluster predictions (categorical)
Returns
- float
Minimum Cluster Ratio
Examples
>>> import numpy as np >>> from holisticai.bias.metrics import min_cluster_ratio >>> 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_cluster = np.array([0, 1, 1, 2, 0, 0, 0, 0, 1, 2]) >>> min_cluster_ratio(group_a, group_b, y_pred_cluster) 0.2499999999375