IBM AI Fairness 360

# AI Fairness 360 (AIF360 v0.1.0)

The AI Fairness 360 toolkit is an open-source library to help detect and remove bias in machine learning models. The AI Fairness 360 Python package includes a comprehensive set of metrics for datasets and models to test for biases, explanations for these metrics, and algorithms to mitigate bias in datasets and models.

The AI Fairness 360 interactive experience provides a gentle introduction to the concepts and capabilities. The tutorials and other notebooks offer a deeper, data scientist-oriented introduction. The complete API is also available.

Being a comprehensive set of capabilities, it may be confusing to figure out which metrics and algorithms are most appropriate for a given use case. To help, we have created some guidance material that can be consulted.

We have developed the package with extensibility in mind. This library is still in development. We encourage the contribution of your metrics, explainers, and debiasing algorithms.

Get in touch with us on Slack (invitation here)!

## Supported fairness metrics

• Comprehensive set of group fairness metrics derived from selection rates and error rates
• Comprehensive set of sample distortion metrics
• Generalized Entropy Index (Speicher et al., 2018)

## Setup

Installation is easiest on a Unix system running Python 3.6. See the Troubleshooting section if you have issues with other configurations.

### (Optional) Create a Virtualenv environment

AIF360 requires specific versions of many Python packages which may conflict with other projects on your system. Virtualenv creates an isolated virtual Python environment where these dependencies may be installed safely. If you have trouble installing AIF360, try this first.

mkdir ~/virtualenvs && cd ~/virtualenvs  # this can be wherever you like storing virtualenvs
virtualenv -p python3 aif360             # or substitute your preferred version of Python
source aif360/bin/activate


For Windows, this is a little different:

md C:\virtualenvs             # this can be wherever you like storing virtualenvs
cd C:\virtualenvs
virtualenv -p python3 aif360  # or substitute your preferred version of Python
aif360/Scripts/activate


The shell should now look like (aif360) $. Also, upgrade pip to be safe: (aif360)$ pip install --upgrade pip


To deactivate the environment, run

deactivate


The prompt will return to $. See the Virtualenv User Guide for more details. ### Install with minimal dependencies #### Installation with pip pip install aif360  This package supports Python 2.7, 3.5, and 3.6. However, for Python 2, the BlackBoxAuditing package must be installed manually. #### Manual installation Clone the latest version of this repository: git clone https://github.com/IBM/AIF360  If you'd like to run the examples, download the datasets now and place them in their respective folders as described in aif360/data/README.md. Then, navigate to the root directory of the project and run: pip install .  #### Run the Examples To run the example notebooks, install the additional requirements as follows: pip install -r requirements.txt  Then, follow the Getting Started instructions from PyTorch to download and install the latest version for your machine. Finally, if you did not already, download the datasets as described in aif360/data/README.md but place them in the appropriate sub-folder in ~/virtualenvs/aif360/lib/pythonX.X/site-packages/aif360/data/raw where pythonX.X is the version of python you are using. ### Troubleshooting If you encounter any errors during the installation process, look for your issue here and try the solutions. #### Windows ##### TensorFlow Note: TensorFlow 1.1.0 only supports Python 3.5 officially on Windows. You can get it from python.org. Then, try: pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl  TensorFlow is only required for use with the aif360.algorithms.inprocessing.AdversarialDebiasing class. ##### CVXPY You may need to download the Visual Studio C++ compiler for Python and rerun pip install cvxpy==0.4.11  CVXPY is only required for use with the aif360.algorithms.preprocessing.OptimPreproc class. #### Python 2 Some additional installation is required to use aif360.algorithms.preprocessing.DisparateImpactRemover with Python 2.7. In a directory of your choosing, run: git clone https://github.com/algofairness/BlackBoxAuditing  In the root directory of BlackBoxAuditing, run: echo -n$PWD/BlackBoxAuditing/weka.jar > python2_source/BlackBoxAuditing/model_factories/weka.path
echo "include python2_source/BlackBoxAuditing/model_factories/weka.path" >> MANIFEST.in
pip install --no-deps .


This will produce a minimal installation which satisfies our requirements.

## Using AIF360

The examples directory contains a diverse collection of jupyter notebooks that use AI Fairness 360 in various ways. Both tutorials and demos illustrate working code using AIF360. Tutorials provide additional discussion that walks the user through the various steps of the notebook. See the details about tutorials and demos here

## Project details

### Source Distribution

aif360-0.1.0.tar.gz (103.0 kB view hashes)

Uploaded source

### Built Distributions

aif360-0.1.0-py3-none-any.whl (164.6 kB view hashes)

Uploaded py3

aif360-0.1.0-py2-none-any.whl (164.6 kB view hashes)

Uploaded py2