aif360.sklearn.metrics
.intersection¶
-
aif360.sklearn.metrics.
intersection
(func, y_true, y_pred=None, prot_attr=None, sample_weight=None, return_groups=False, **kwargs)[source]¶ Compute an arbitrary metric on all intersectional groups of the protected attributes provided.
Parameters: - func (function) – A metric function from
sklearn.metrics
oraif360.sklearn.metrics
. - y_true (pandas.Series) – Outcome vector with protected attributes as index.
- y_pred (array-like, optional) – Estimated outcomes.
- prot_attr (array-like, keyword-only) – Protected attribute(s). If
None
, all protected attributes in y are used. - sample_weight (array-like, optional) – Sample weights passed through to func.
- return_groups (bool, optional) – Return group names in addition to metric values. Names are tuples of protected attribute values.
- **kwargs – Additional keyword args to be passed through to func.
Returns: list – List of metric values for each intersectional group.
- tuple:
Metric values and their corresponding group names.
- vals (
list
) – List of metric values for each intersectional group - groups (
numpy.ndarray
) – Array of tuples containing unique intersectional groups derived from the provided protected attributes.
- vals (
Examples
>>> X, y = fetch_german() >>> v, k = intersection(base_rate, y, prot_attr=['sex', 'age'], ... return_groups=True, pos_label='good') >>> dict(zip(k, v)) {('female', 'aged'): 0.697560975609756, ('female', 'young'): 0.5523809523809524, ('male', 'aged'): 0.7388429752066116, ('male', 'young'): 0.611764705882353}
- func (function) – A metric function from