aif360.sklearn.metrics
.conditional_demographic_disparity¶
-
aif360.sklearn.metrics.
conditional_demographic_disparity
(y_true, y_pred=None, *, prot_attr=None, pos_label=1, sample_weight=None)[source]¶ Conditional demographic disparity, \(CDD = \frac{1}{\sum_i N_i} \sum_i N_i\cdot DD_i\)
where \(DD_i = \frac{N_{i, -}}{\sum_j N_{j, -}} - \frac{N_{i, +}}{ \sum_j N_{j, +}}\).
\(N_{i, +}\) signifies the number of samples belonging to group \(i\) that have favorable labels while \(N_{i, -}\) signifies those that have negative labels [1].
Parameters: - y_true (pandas.Series) – Ground truth (correct) target values. If y_pred is provided, this is ignored.
- y_pred (array-like) – Estimated targets as returned by a classifier.
- prot_attr (array-like, keyword-only) – Protected attribute(s). If
None
, all protected attributes in y_true are used. - pos_label (scalar, optional) – The label of the positive class.
- sample_weight (array-like, optional) – Sample weights.
Returns: float – Conditional demographic disparity.
References
[1] S. Wachter, B. Mittelstadt, and C. Russell, “Why fairness cannot be automated: Bridging the gap between EU non-discrimination law and AI,” Computer Law & Security Review, Volume 41, 2021.