LFR¶
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
- class fairdiverse.search.preprocessing_model.LFR.LFR(configs, dataset)[source]¶
Bases:
PreprocessingFairnessIntervention
Learning Fair Representations (LFR) fairness intervention.
This class applies the LFR approach to modify the dataset such that fairness constraints are met while preserving as much utility as possible.
- fit(X_train, run)[source]¶
Train the LFR fairness model using the given training dataset.
This method optimizes a fairness objective by learning fair representations of the data using constrained optimization.
- :param X_trainpandas.DataFrame or numpy.ndarray
The training dataset. It is assumed that the last non-sensitive column is the target variable.
- :param runstr
The identifier for the training run.
- :returnself
The trained LFR model.
- transform(X, run, file_name=None)[source]¶
Apply the fairness transformation to the dataset using the learned model.
This method ensures fairness by adjusting feature distributions while maintaining data utility.
- :param Xpandas.DataFrame
The dataset to which the fairness transformation is applied.
- :param runstr
The identifier for the transformation run.
- :param file_namestr, optional
Name of the file to save the transformed dataset.
- :returnpandas.DataFrame
The dataset with transformed fair columns.