fairlearn.metrics.demographic_parity_ratio#

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

Calculate the demographic parity ratio.

The demographic parity ratio is defined as the ratio between the smallest and the largest group-level selection rate, \(E[h(X) | A=a]\), across all values \(a\) of the sensitive feature(s). The demographic parity ratio of 1 means that all groups have the same selection rate.

Read more in the User Guide.

Parameters:
  • y_true (array-like) – Ground truth (correct) labels.

  • y_pred (array-like) – Predicted labels \(h(X)\) returned by the classifier.

  • sensitive_features – The sensitive features over which demographic parity should be assessed

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

  • sample_weight (array-like) – The sample weights

Returns:

The demographic parity ratio

Return type:

float