Skip to main content

Unified framework for assessing and improving classification fairness.

Project description

Fairlib

Fairlib is a Python framework for assessing and improving classification fairness. Built-in algorithms can be applied to text inputs, structured inputs, and image inputs.

The Fairlib package includes metrics for fairness evaluation, algorithms for bias mitigation, and functions for analysis.

For those who want to start with Fairlib now, you can try our Colab Tutorial, which provides a gentle introduction to the concepts and capabilities. The tutorials and other notebooks offer a deeper introduction. The complete API is also available.

Table of contents

Installation

Fairlib currently requires Python3.7+ and Pytorch 1.10 or higher. Dependencies of the core modules are listed in requirements.txt. We strongly recommend using a venv or conda environment for installation.

Standard Installation

If you do not need further modifications, you can install it with:

# Start a new virtual environment:
conda create -n fairlib python=3.7
conda activate fairlib

pip install faircls

Development Installation

To set up a development environment, run the following commands to clone the repository and install Fairlib:

git clone https://github.com/HanXudong/fairlib.git ~/fairlib
cd ~/fairlib; python setup.py develop

Benchmark Datasets

Please refer to data/README.md for a list of fairness benchmark datasets.

Usage

The full description of Fairlib usages can be found in docs/usage. Here are the most basic examples.

  • Fairlib can be run from the command line:

    python fairlib --exp_id EXP_NAME
    
  • Fairlib can be imported as a package

    from fairlib.base_options import options
    from src import networks
    
    config_file = 'opt.yaml'
    # Get options
    state = options.get_state(conf_file=config_file)
    
    # Init the model
    model = networks.get_main_model(state)
    
    # Training with debiasing
    model.train_self()
    

Model Selection and Fairness Evaluation

We provide implementation of DTO and DTO based model selection for different models.

Please see this tutorial for an example of loading training history, performing model selections based on different strategies, and creating basic plots. Moreover, interactive plots are also supported, which can be used for analysis.

Known issues and limitations

None are known at this time.

Getting help

If you have any problem with our code or have some suggestions, including the future feature, feel free to contact

or describe it in Issues.

Contributing

We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.

License

This project is distributed under the terms of the APACHE LICENSE, VERSION 2.0. The license applies to all files in the GitHub repository hosting this file.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fairlib-0.0.3.tar.gz (49.9 kB view details)

Uploaded Source

Built Distribution

fairlib-0.0.3-py3-none-any.whl (63.8 kB view details)

Uploaded Python 3

File details

Details for the file fairlib-0.0.3.tar.gz.

File metadata

  • Download URL: fairlib-0.0.3.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.12

File hashes

Hashes for fairlib-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3a963dfba77f74bbfdd2d952d1325082a31daa17634b53faab7287cfcfd524d3
MD5 e02975f72b22f1784eb116f00a5f6ca6
BLAKE2b-256 bd8f6937249d8c117631859cf0436c8681a5ca35c52317afefaf751c45bd8805

See more details on using hashes here.

File details

Details for the file fairlib-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: fairlib-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 63.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.12

File hashes

Hashes for fairlib-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b197be8f590216f8aed68ae1a7b53cfa045cdd0a88713917d26404ff035fc030
MD5 4d543527935b48f397f0dd0df731dc81
BLAKE2b-256 59acd91954a8d0e0bb753ef3a2d8b9468f89cf5f6820d2795617ad1738370690

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page