aif360.sklearn.utils
.check_groups¶
-
aif360.sklearn.utils.
check_groups
(arr, prot_attr, ensure_binary=False)[source]¶ Get groups from the index of arr.
If there are multiple protected attributes provided, the index is flattened to be a 1-D Index of tuples. If ensure_binary is
True
, raises a ValueError if there are not exactly two unique groups. Also checks that all provided protected attributes are in the index.Parameters: - arr (
pandas.Series
orpandas.DataFrame
) – A Pandas object containing protected attribute information in the index. - prot_attr (single label or list-like) – Protected attribute(s). If
None
, all protected attributes in arr are used. - ensure_binary (bool) – Raise an error if the resultant groups are not binary.
Returns: tuple –
- groups (
pandas.Index
) – Label (or tuple of labels) of protected attribute for each sample in arr. - prot_attr (
list-like
) – Modified input. If input is a single label, returns single-item list. If input isNone
returns list of all protected attributes.
- arr (