aif360.algorithms.preprocessing
.LFR
- class aif360.algorithms.preprocessing.LFR(unprivileged_groups, privileged_groups, k=5, Ax=0.01, Ay=1.0, Az=50.0, print_interval=250, verbose=0, seed=None)[source]
Learning fair representations is a pre-processing technique that finds a latent representation which encodes the data well but obfuscates information about protected attributes [2]. .. rubric:: References
Based on code from https://github.com/zjelveh/learning-fair-representations
- Parameters:
unprivileged_groups (tuple) – Representation for unprivileged group.
privileged_groups (tuple) – Representation for privileged group.
k (int, optional) – Number of prototypes.
Ax (float, optional) – Input recontruction quality term weight.
Az (float, optional) – Fairness constraint term weight.
Ay (float, optional) – Output prediction error.
print_interval (int, optional) – Print optimization objective value every print_interval iterations.
verbose (int, optional) – If zero, then no output.
seed (int, optional) – Seed to make
predict
repeatable.
Methods
Compute the transformation parameters that leads to fair representations.
fit_predict
Train a model on the input and predict the labels.
Fit and transform methods sequentially.
predict
Return a new dataset with labels predicted by running this Transformer on the input.
Transform the dataset using learned model parameters.
- __init__(unprivileged_groups, privileged_groups, k=5, Ax=0.01, Ay=1.0, Az=50.0, print_interval=250, verbose=0, seed=None)[source]
- Parameters:
unprivileged_groups (tuple) – Representation for unprivileged group.
privileged_groups (tuple) – Representation for privileged group.
k (int, optional) – Number of prototypes.
Ax (float, optional) – Input recontruction quality term weight.
Az (float, optional) – Fairness constraint term weight.
Ay (float, optional) – Output prediction error.
print_interval (int, optional) – Print optimization objective value every print_interval iterations.
verbose (int, optional) – If zero, then no output.
seed (int, optional) – Seed to make
predict
repeatable.
- fit(dataset, maxiter=5000, maxfun=5000)[source]
Compute the transformation parameters that leads to fair representations. :param dataset: Dataset containing true labels. :type dataset: BinaryLabelDataset :param maxiter: Maximum number of iterations. :type maxiter: int :param maxfun: Maxinum number of function evaluations. :type maxfun: int
- Returns:
LFR – Returns self.
- fit_transform(dataset, maxiter=5000, maxfun=5000, threshold=0.5)[source]
Fit and transform methods sequentially.
- Parameters:
dataset (BinaryLabelDataset) – Dataset containing labels that needs to be transformed.
maxiter (int) – Maximum number of iterations.
maxfun (int) – Maxinum number of function evaluations.
threshold (float, optional) – threshold parameter used for binary label prediction.
- Returns:
dataset (BinaryLabelDataset) – Transformed Dataset.
- transform(dataset, threshold=0.5)[source]
Transform the dataset using learned model parameters. :param dataset: Dataset containing labels that needs to be transformed. :type dataset: BinaryLabelDataset :param threshold: threshold parameter used for binary label prediction. :type threshold: float, optional
- Returns:
dataset (BinaryLabelDataset) – Transformed Dataset.