fairlearn.metrics.equal_opportunity_difference(y_true, y_pred, *, sensitive_features, method='between_groups', sample_weight=None)[source]#

Calculate the equal opportunity difference.

The equal opportunity difference is defined as the difference between the largest and the smallest group-level true positive rates, \(E[h(X) | A=a]\), across all values \(a\) of the sensitive feature(s). The equal opportunity difference of 0 means that all groups have the same true positive rate.

Read more in the User Guide.

  • 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 equal opportunity should be assessed

  • method (str) – How to compute the differences. See fairlearn.metrics.MetricFrame.difference() for details.

  • sample_weight (array-like) – The sample weights


The equal opportunity difference

Return type: