Giter VIP home page Giter VIP logo

bayesian-fairness-assess's Introduction

This is the code for our paper, "Can I Trust My Fairness Metric? Assessing Fairness with Unlabeled Data and Bayesian Inference."

Getting started

To setup virtual environment install dependencies in requirements.txt:

conda create -n bayesian-fairness python=3.7
source activate bayesian-fairness
pip install -r requirements.txt

Datasets

  • Download .csv files for 6 datasets used in the paper form data directory

Preprocess and benchmark

  • Preprocess with python fairness_comparison/preprocess.py
  • Train classifers and write predicted scores to file with python fairness_comparison/benchmark.py

Train calibration models

Our implementation supports 4 different methods to provide estimates about groupwise fairness metrics ($\Delta$ Accuracy, $\Delta$ TPR, $\Delta$ FNR, etc), including:

  • hierarchical beta binomial model: src/hierarchical_beta_binomial.py
  • hierarchical llo calibration: src/hierarchical_llo_calibration.py
  • beta binomial: src/beta_binomial.py
  • hierarchical beta calibration: src/hierarchical_beta_calibration.py

We provide an example to train calibration models on adult data with sensitive attribute sex.

# navigate to source code directory
cd src

# map string attributes/labels to numbers
python remap.py

# define the list of methods
declare -a MethodArray=("hierarchical_beta_binomial" "hierarchical_llo_calibration" "beta_binomial" "hierarchical_beta_calibration")

# train calibration models with different values of n_L, 100 independent runs
for method in "${MethodArray[@]}"
do
    for n in {2,5,10,20,40,60,80,100,200,400,600,800,1000,10054}
    do
        for i in {0..100}
        do
            python $method.py -dataset adult -attribute sex -num_groups 2 -budget $n -run_id $i
        done
    done
done

Infer fairness metrics

To infer fairness metrics including $\Delta$ TPR and $\Delta$ FNR on adult data with sensitive attribute sex, $n_L$=100:

python hierarchical_beta_conditional_metrics.py  -dataset adult -attribute sex -num_groups 2 -num_runs 100 -budget 100

To reproduce the results reported in the paper and supplements

  • cd src
  • bash script

References

Please consider citing our paper if you found this work useful!

@inproceedings{ji2020can,
  title={Can I Trust My Fairness Metric? {A}ssessing Fairness with Unlabeled Data and {B}ayesian Inference},
  author={Ji, Disi and Smyth, Padhraic and Steyvers, Mark},
  booktitle={Advances in Neural Information Processing Systems},
  year={2020}
}

Contact

This code was developed by Disi Ji. Reach out to me with any questions! My email is : [email protected].

bayesian-fairness-assess's People

Contributors

disiji avatar

Stargazers

 avatar Mingzhe Yang avatar Dylan Slack avatar

Watchers

James Cloos avatar  avatar

Forkers

derekozhang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.