fairlearn.metrics.demographic_parity_difference#
- fairlearn.metrics.demographic_parity_difference(y_true, y_pred, *, sensitive_features, method='between_groups', sample_weight=None)[source]#
Calculate the demographic parity difference.
The demographic parity difference is defined as the difference between the largest and the smallest group-level selection rate, \(E[h(X) | A=a]\), across all values \(a\) of the sensitive feature(s). The demographic parity difference of 0 means that all groups have the same selection rate.
Read more in the User Guide.
Added in version 0.4.6.
- Return type:
- Parameters:
- y_truearray_like
Ground truth (correct) labels.
- y_predarray_like
Predicted labels \(h(X)\) returned by the classifier.
- sensitive_featuresarray_like
The sensitive features over which demographic parity should be assessed
- method
str{‘between_groups’, ‘to_overall’}, defaultbetween_groups How to compute the differences. See
fairlearn.metrics.MetricFrame.difference()for details.- sample_weightarray_like
The sample weights
- Returns:
floatThe demographic parity difference