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=1, 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].
References
[2] R. Zemel, Y. Wu, K. Swersky, T. Pitassi, and C. Dwork, “Learning Fair Representations.” International Conference on Machine Learning, 2013. 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
predictrepeatable.
Methods
fitCompute the transformation parameters that leads to fair representations. fit_predictTrain a model on the input and predict the labels. fit_transformfit and transform methods sequentially predictReturn a new dataset with labels predicted by running this Transformer on the input. transformTransform 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=1, 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
predictrepeatable.
-
fit(dataset, **kwargs)[source]¶ Compute the transformation parameters that leads to fair representations.
Parameters: dataset (BinaryLabelDataset) – Dataset containing true labels. Returns: LFR – Returns self.
-
transform(dataset, threshold=0.5, **kwargs)[source]¶ Transform the dataset using learned model parameters.
Parameters: - dataset (BinaryLabelDataset) – Dataset containing labels that needs to be transformed.
- threshold (float, optional) – threshold parameter used for binary label prediction.
Returns: dataset (BinaryLabelDataset) – Transformed Dataset.