fairlearn.metrics.equalized_odds_difference#
- fairlearn.metrics.equalized_odds_difference(y_true, y_pred, *, sensitive_features, method='between_groups', sample_weight=None, agg='worst_case')[source]#
Calculate the equalized odds difference.
Depending on the agg parameter, this function computes either:
The greater of two metrics: true_positive_rate_difference and false_positive_rate_difference, if agg=’worst_case’. The former is the difference between the largest and smallest of \(P[h(X)=1 | A=a, Y=1]\), across all values \(a\) of the sensitive feature(s). The latter is defined similarly, but for \(P[h(X)=1 | A=a, Y=0]\).
The mean of these two metrics, if agg=’mean’.
The equalized odds difference of 0 means that all groups have the same true positive, true negative, false positive, and false negative rates.
Read more in the User Guide.
Added in version 0.4.6.
- Parameters:
y_true (array_like) – Ground truth (correct) labels.
y_pred (array_like) – Predicted labels \(h(X)\) returned by the classifier.
sensitive_features (array_like) – The sensitive features over which equalized odds should be assessed
method (
Literal['between_groups','to_overall']) – How to compute the differences. Seefairlearn.metrics.MetricFrame.difference()for details.sample_weight (array_like) – The sample weights
agg (
Literal['worst_case','mean']) – The aggregation method. One of “worst_case” or “mean”. If “worst_case”, the greater one of the false positive rate difference and true positive rate difference is returned. If “mean”, the mean of the differences is returned.
- Return type:
- Returns:
The equalized odds difference
- Raises:
ValueError – If agg is not one of
'worst_case'or'mean'.