holisticai.bias.metrics.cluster_dist_entropy#

holisticai.bias.metrics.cluster_dist_entropy(group, y_pred)[source]#

Minority Cluster Distribution Entropy

The entropy of the distribution of the group over the clusters.

Interpretation

Lower values indicate most members of the group are allocated to the same cluaster. Hence we encourage higher values of the entropy, which indicate more homogeneity.

Parameters

grouparray-like

Group membership vector (binary)

y_predarray-like

Cluster predictions (categorical)

Returns

float

Group Presence Entropy

Notes

\(Entropy(P_{group})\)

Examples

>>> import numpy as np
>>> from holisticai.bias.metrics import cluster_dist_entropy
>>> 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])
>>> cluster_dist_entropy(group_b, y_pred_cluster)
0.8675632284814613