aif360.algorithms.preprocessing
.OptimPreproc
- class aif360.algorithms.preprocessing.OptimPreproc(optimizer, optim_options, unprivileged_groups=None, privileged_groups=None, verbose=False, seed=None)[source]
Optimized preprocessing is a preprocessing technique that learns a probabilistic transformation that edits the features and labels in the data with group fairness, individual distortion, and data fidelity constraints and objectives [3].
References
Based on code available at: https://github.com/fair-preprocessing/nips2017
- Parameters:
optimizer (class) – Optimizer class.
optim_options (dict) – Options for optimization to estimate the transformation.
unprivileged_groups (dict) – Representation for unprivileged group.
privileged_groups (dict) – Representation for privileged group.
verbose (bool, optional) – Verbosity flag for optimization.
seed (int, optional) – Seed to make
fit
andpredict
repeatable.
Note
This algorithm does not use the privileged and unprivileged groups that are specified during initialization yet. Instead, it automatically attempts to reduce statistical parity difference between all possible combinations of groups in the dataset.
Methods
Compute optimal pre-processing transformation based on distortion constraint.
fit_predict
Train a model on the input and predict the labels.
Perfom
fit()
andtransform()
sequentially.predict
Return a new dataset with labels predicted by running this Transformer on the input.
Transform the dataset to a new dataset based on the estimated transformation.
- __init__(optimizer, optim_options, unprivileged_groups=None, privileged_groups=None, verbose=False, seed=None)[source]
- Parameters:
optimizer (class) – Optimizer class.
optim_options (dict) – Options for optimization to estimate the transformation.
unprivileged_groups (dict) – Representation for unprivileged group.
privileged_groups (dict) – Representation for privileged group.
verbose (bool, optional) – Verbosity flag for optimization.
seed (int, optional) – Seed to make
fit
andpredict
repeatable.
Note
This algorithm does not use the privileged and unprivileged groups that are specified during initialization yet. Instead, it automatically attempts to reduce statistical parity difference between all possible combinations of groups in the dataset.
- fit(dataset, sep='=')[source]
Compute optimal pre-processing transformation based on distortion constraint.
- Parameters:
dataset (BinaryLabelDataset) – Dataset containing true labels.
sep (str, optional) – Separator for converting one-hot labels to categorical.
- Returns:
OptimPreproc – Returns self.
- fit_transform(dataset, sep='=', transform_Y=True)[source]
Perfom
fit()
andtransform()
sequentially.
- transform(dataset, sep='=', transform_Y=True)[source]
Transform the dataset to a new dataset based on the estimated transformation.
- Parameters:
dataset (BinaryLabelDataset) – Dataset containing labels that needs to be transformed.
transform_Y (bool) – Flag that mandates transformation of Y (labels).