Skip to content

hk-mp5a3/FairMI

 
 

Repository files navigation

Source Code


In Fair Classification without Constraints: A feature Pruning Approach, we propose a pre-processing approach that prunes the features that are highly correlated with the protected attributes. In this repository, we conduct several experiments to compare test error, fairness violation, and runtime among different methods.

Setup

  • Recommended Python version: 3.7.7
  • Python package installation:
$ pip install -r requirements.txt 
  • Create directory for results and figures
$ mkdir figures
$ mkdir results
  • Create directory for CelebA processed data
$ mkdir celeba

which should include the following files generated by celeba.ipynb

  • celeba.test.npy
  • celeba.train.npy
  • celeba_label.test.npy
  • celeba_label.train.npy

Usage

Run Pipeline and Plot Figures

python main.py [options arguments here]
optional arguments:
    -n                  int, number of features to drop, default: 20
    --noise_rate        float, the percentage of samples to add noise, default: 0.0
    --repeats           int, number of times to repeat the experiment, default: 5
    --grid_size         int, number of Lagrange multipliers to generate in the grid, default: 5
    --asymmetric_noise  boolean, whether the noise is asymmetric, default: False
    --lambda_value      float, lambda value for dropping features, default: 0.0
    --model             string, specify the base classifier for training, should be one of 'LR'(Logistic Regression), 'SVM'(Support Vector Machine), 'MLP'(Multi-layer Perceptron), default: 'LR'
    --constraints       string, specify fairness violation, should be one of 'DP'(Demographic Parity) and 'EO'(Equalized Odds), default: 'DP'
    --partitions        int, the number of partitions for constraint weight in GridSearch. For example, if partitions=5, then the program will use 0. , 0.2, 0.4, 0.6, 0.8, and 1. as constraint weight for training perspectively. default: 5
    --datasets          string, the dataset used for training, should be one of 'adult_sex'(adult dataset, sex as sensitive attribtue), 'adult_race'(adult dataset, race as sensitive attribtue), 'adult_sex_race'(adult dataset, sex and race as sensitive attribtues), 'compas'(compas dataset, race as sensitive attribtue), 'celeba'(CelebA dataset, gender as sensitive attribute), 'celeba_young_male'(CelebA dataset, young and gender as sensitive attribtues). default: 'adult_sex'

Example:

$ python main.py --dataset=celeba -n=128 --constraint=EO --noise_rate=0.3 --asymmetric_noise=True

Runtime Analysis

python runtime_analysis.py [options arguments here]

Option arguments same as above. Example:

$ python runtime_analysis.py --dataset=celeba -n=128 --constraint=EO --noise_rate=0.3 --asymmetric_noise=True

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 76.3%
  • Python 23.7%