aif360.algorithms.postprocessing.CalibratedEqOddsPostprocessing

class aif360.algorithms.postprocessing.CalibratedEqOddsPostprocessing(unprivileged_groups, privileged_groups, cost_constraint='weighted', seed=None)[source]

Calibrated equalized odds postprocessing is a post-processing technique that optimizes over calibrated classifier score outputs to find probabilities with which to change output labels with an equalized odds objective [7].

References

Adapted from: https://github.com/gpleiss/equalized_odds_and_calibration/blob/master/calib_eq_odds.py

Parameters:
  • unprivileged_groups (dict or list(dict)) – Representation for unprivileged group.

  • privileged_groups (dict or list(dict)) – Representation for privileged group.

  • cost_contraint – fpr, fnr or weighted

  • seed (int, optional) – Seed to make predict repeatable.

Methods

fit

Compute parameters for equalizing generalized odds using true and predicted scores, while preserving calibration.

fit_predict

fit and predict methods sequentially.

fit_transform

Train a model on the input and transform the dataset accordingly.

predict

Perturb the predicted scores to obtain new labels that satisfy equalized odds constraints, while preserving calibration.

transform

Return a new dataset generated by running this Transformer on the input.

__init__(unprivileged_groups, privileged_groups, cost_constraint='weighted', seed=None)[source]
Parameters:
  • unprivileged_groups (dict or list(dict)) – Representation for unprivileged group.

  • privileged_groups (dict or list(dict)) – Representation for privileged group.

  • cost_contraint – fpr, fnr or weighted

  • seed (int, optional) – Seed to make predict repeatable.

fit(dataset_true, dataset_pred)[source]

Compute parameters for equalizing generalized odds using true and predicted scores, while preserving calibration.

Parameters:
Returns:

CalibratedEqOddsPostprocessing – Returns self.

fit_predict(dataset_true, dataset_pred, threshold=0.5)[source]

fit and predict methods sequentially.

predict(dataset, threshold=0.5)[source]

Perturb the predicted scores to obtain new labels that satisfy equalized odds constraints, while preserving calibration.

Parameters:
  • dataset (BinaryLabelDataset) – Dataset containing scores that needs to be transformed.

  • threshold (float) – Threshold for converting scores to labels. Values greater than or equal to this threshold are predicted to be the favorable_label. Default is 0.5.

Returns:

dataset (BinaryLabelDataset) – transformed dataset.