aif360.sklearn.metrics
.class_imbalance
- aif360.sklearn.metrics.class_imbalance(y_true, y_pred=None, *, prot_attr=None, priv_group=1, sample_weight=None)[source]
Compute the class imbalance, \(\frac{N_u - N_p}{N_u + N_p}\).
Where \(N_u\) is the number of samples in the unprivileged group and \(N_p\) is the number of samples in the privileged group.
- Parameters:
y_true (pandas.Series) – Ground truth (correct) target values.
y_pred (array-like, optional) – Estimated targets. Ignored.
prot_attr (array-like, keyword-only) – Protected attribute(s). If
None
, all protected attributes in y_true are used.priv_group (scalar) – The label of the privileged group.
sample_weight (array-like, optional) – Sample weights.
- Returns:
float – Class imbalance.