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:
Methods
Compute parameters for equalizing generalized odds using true and predicted scores, while preserving calibration.
fit and predict methods sequentially.
fit_transform
Train a model on the input and transform the dataset accordingly.
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.
- fit(dataset_true, dataset_pred)[source]
Compute parameters for equalizing generalized odds using true and predicted scores, while preserving calibration.
- Parameters:
dataset_true (BinaryLabelDataset) – Dataset containing true
labels
.dataset_pred (BinaryLabelDataset) – Dataset containing predicted
scores
.
- 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
tolabels
. Values greater than or equal to this threshold are predicted to be thefavorable_label
. Default is 0.5.
- Returns:
dataset (BinaryLabelDataset) – transformed dataset.