This repository contains the code to reproduce the experiments in our paper Characterizing the risk of fairwashing.
The project requires the following python packages:
- numpy
- pandas
- h5py
- mpi4py
- scikit-learn
- xgboost
- tensorflow
- faircorels
- fairlearn
The R scripts requires the following R packages:
- tidyverse
- here
- ranger
cd preprocessing
source main.sh
cd models
source main.sh
Use LaundryML.py for rule list explainers and LaundryML_Fairlearn.py for decision tree and logistic regression explainers.
Assuming nbr_core is the number of core you want to use:
cd core
mpiexec -n nbr_core python LaundryML.py
You will have to provide the number of cores in your submission file and srun will use all the core available:
cd core
srun python LaundryML.py
dataset
(int): Dataset Id. 1: Adult Income, 2: COMPAS, 3: Default Credit, or 4: Marketingrseed
(int): Id of the sample. Choose between 0 and 9metric
(in): Fairness metric Id: 1: SP, 2: PP, 3: PE, 4: EOpp, 5: EOdds, or 6: CUAE'model_class
(string): Black-box model. AdaBoost: AdaBoost classifier, DNN: Deep neural network, RF: Random Forest, or XgBoost: XgBoost classifiertransfer
(int): Boolean indicator to perform the transferability attack. 1: Yes, 0: No
We assume that you have done all the experiments fairwashing attacks, generalization evaluations, and tranferability attacks for all the four datasets, fairness metrics, and black-box models.
Results are saved in analysis/results. The summary of the performances of the black-box models is saved in analysis/results/latex/perfs.tex.
cd analysis
source get_results.sh
Results are saved in analysis/plotting_scripts/results.
cd plotting_scripts
Rscript pareto_fronts.R
Rscript half_unfairness_all.R
Rscript transferability.R
For this part of the experiments, we rely on the code provided by the autors of the paper "Characterizing Fairness Over the Set of Good Models Under Selective Labels" (https://arxiv.org/abs/2101.00352). The original code is available at https://github.com/asheshrambachan/Fairness_In_The_Rashomon_Set.
cd quantifying_fairwashing
source compute_unfairness_range.sh
source merge_results.sh
cd quantifying_fairwashing/plotting_scripts
Rscript analysis.R