A comprehensive set of fairness metrics for datasets and machine learning models, explanations for these metrics, and algorithms to mitigate bias in datasets and models.

Overview

AI Fairness 360 (AIF360)

Continuous Integration Documentation PyPI version CRAN_Status_Badge

The AI Fairness 360 toolkit is an extensible open-source library containg techniques developed by the research community to help detect and mitigate bias in machine learning models throughout the AI application lifecycle. AI Fairness 360 package is available in both Python and R.

The AI Fairness 360 package includes

  1. a comprehensive set of metrics for datasets and models to test for biases,
  2. explanations for these metrics, and
  3. algorithms to mitigate bias in datasets and models. It is designed to translate algorithmic research from the lab into the actual practice of domains as wide-ranging as finance, human capital management, healthcare, and education. We invite you to use it and improve it.

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 bias mitigation algorithms

Supported fairness metrics

  • Comprehensive set of group fairness metrics derived from selection rates and error rates including rich subgroup fairness
  • Comprehensive set of sample distortion metrics
  • Generalized Entropy Index (Speicher et al., 2018)
  • Differential Fairness and Bias Amplification (Foulds et al., 2018)
  • Bias Scan with Multi-Dimensional Subset Scan (Zhang, Neill, 2017)

Setup

R

install.packages("aif360")

For more details regarding the R setup, please refer to instructions here.

Python

Supported Python Configurations:

OS Python version
macOS 3.6, 3.7, 3.8
Ubuntu 3.6, 3.7, 3.8
Windows 3.6, 3.7, 3.8

(Optional) Create a virtual environment

AIF360 requires specific versions of many Python packages which may conflict with other projects on your system. A virtual environment manager is strongly recommended to ensure dependencies may be installed safely. If you have trouble installing AIF360, try this first.

Conda

Conda is recommended for all configurations though Virtualenv is generally interchangeable for our purposes. Miniconda is sufficient (see the difference between Anaconda and Miniconda if you are curious) if you do not already have conda installed.

Then, to create a new Python 3.6 environment, run:

conda create --name aif360 python=3.6
conda activate aif360

The shell should now look like (aif360) $. To deactivate the environment, run:

(aif360)$ conda deactivate

The prompt will return to $ .

Note: Older versions of conda may use source activate aif360 and source deactivate (activate aif360 and deactivate on Windows).

Install with pip

To install the latest stable version from PyPI, run:

pip install aif360

Note: Some algorithms require additional dependencies (although the metrics will all work out-of-the-box). To install with certain algorithm dependencies included, run, e.g.:

pip install 'aif360[LFR,OptimPreproc]'

or, for complete functionality, run:

pip install 'aif360[all]'

The options for available extras are: OptimPreproc, LFR, AdversarialDebiasing, DisparateImpactRemover, LIME, ART, Reductions, notebooks, tests, docs, all

If you encounter any errors, try the Troubleshooting steps.

Manual installation

Clone the latest version of this repository:

git clone https://github.com/Trusted-AI/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 --editable '.[all]'

Run the Examples

To run the example notebooks, complete the manual installation steps above. Then, if you did not use the [all] option, install the additional requirements as follows:

pip install -e '.[notebooks]'

Finally, if you did not already, download the datasets as described in aif360/data/README.md.

Troubleshooting

If you encounter any errors during the installation process, look for your issue here and try the solutions.

TensorFlow

See the Install TensorFlow with pip page for detailed instructions.

Note: we require 'tensorflow >= 1.13.1'.

Once tensorflow is installed, try re-running:

pip install 'aif360[AdversarialDebiasing]'

TensorFlow is only required for use with the aif360.algorithms.inprocessing.AdversarialDebiasing class.

CVXPY

On MacOS, you may first have to install the Xcode Command Line Tools if you never have previously:

xcode-select --install

On Windows, you may need to download the Microsoft C++ Build Tools for Visual Studio 2019. See the CVXPY Install page for up-to-date instructions.

Then, try reinstalling via:

pip install 'aif360[OptimPreproc]'

CVXPY is only required for use with the aif360.algorithms.preprocessing.OptimPreproc class.

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

Citing AIF360

A technical description of AI Fairness 360 is available in this paper. Below is the bibtex entry for this paper.

@misc{aif360-oct-2018,
    title = "{AI Fairness} 360:  An Extensible Toolkit for Detecting, Understanding, and Mitigating Unwanted Algorithmic Bias",
    author = {Rachel K. E. Bellamy and Kuntal Dey and Michael Hind and
	Samuel C. Hoffman and Stephanie Houde and Kalapriya Kannan and
	Pranay Lohia and Jacquelyn Martino and Sameep Mehta and
	Aleksandra Mojsilovic and Seema Nagar and Karthikeyan Natesan Ramamurthy and
	John Richards and Diptikalyan Saha and Prasanna Sattigeri and
	Moninder Singh and Kush R. Varshney and Yunfeng Zhang},
    month = oct,
    year = {2018},
    url = {https://arxiv.org/abs/1810.01943}
}

AIF360 Videos

  • Introductory video to AI Fairness 360 by Kush Varshney, September 20, 2018 (32 mins)

Contributing

The development fork for Rich Subgroup Fairness (inprocessing/gerryfair_classifier.py) is here. Contributions are welcome and a list of potential contributions from the authors can be found here.

Comments
  • Fairadapt inclusion in AIF360

    Fairadapt inclusion in AIF360

    Hi guys,

    Here is a pull request adding three files we mentioned (fairadapt.py, test_fairadapt.py and demo_fairadapt.ipynb).

    Most importantly: the installation of the necessary R-packages using rpy2 is currently done from the fairadapt class (check fairadapt.py line 54). I am guessing you would be looking for a better solution, i.e., that R-packages are installed together with AIF. Please just make sure, if this option is used, that we have installed:

    • ranger version 0.13.1
    • fairadapt version 0.2.0

    Both of the above are now available via CRAN, which should make installing them using conda much easier!

    Thank you in advance for attending to this!

    Best, Drago

    opened by dplecko 13
  • Support for MacOS

    Support for MacOS

    What OS was AIF360 built on? I'm attempting to run on a Macbook Pro with the latest Mac OS however I am getting errors when attempting to install the module 'cvxpy'. During the 'pip install cvxpy', I get numerous compilation errors:

      warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      In file included from cvxpy/cvxcore/src/cvxcore.cpp:15:
      cvxpy/cvxcore/src/cvxcore.hpp:18:10: fatal error: 'vector' file not found
      #include <vector>
               ^~~~~~~~
      1 warning and 1 error generated.
      error: command 'gcc' failed with exit status 1
      
      ----------------------------------------
      Failed building wheel for cvxpy
    
    opened by biosopher 13
  • Dataset Improvements

    Dataset Improvements

    Major improvements:

    • Changed how prot_attr arguments are handled. Now, when processing a dataset and running metrics, an explicit array (or list of arrays) containing protected attribute values per sample may be passed instead of requiring an index name.
    • Added MEPS, COMPAS violent datasets (#150)

    Small changes:

    • Added cache=False option to dataset fetching functions to skip caching
    • Removed unused categories from DataFrame resulting from dropped rows
    opened by hoffmansc 12
  • Update component.yaml to kfp v2 sdk

    Update component.yaml to kfp v2 sdk

    Update component.yaml to kfp v2 compatible. In v2, you need to declare the data type for all of the input/output arguments.

    Signed-off-by: Yihong Wang [email protected]

    opened by yhwang 8
  • Executing the Credit Risk notebook does not generate a de-biased dataset

    Executing the Credit Risk notebook does not generate a de-biased dataset

    Executing the Credit Risk Notebook does not generate a de-biased dataset. The results below are from a brand now GIT pull from the AIF360 repo. As shown at the end, the new "debiased" model now over twice as biased as the original model:

    image image image

    opened by biosopher 8
  • Reconcile code and docstring for consistency_score and consistency

    Reconcile code and docstring for consistency_score and consistency

    The documentation for the functions consistency_score and consistency match the paper, which has a factor of 1 over k (k=n_neighbors in the AIF360 documentation) to the left of the outer sum, rather than to the left of the inner sum. The code in both functions does not match the documentation since it takes the mean of y for the k nearest neighbours (rather than the sum) and doesn't divide the outer sum by n_neighbors.

    To see the error in the previous documentation, consider the extreme case where y_hat = 1 for all examples. Here the consistency_score should be 1 as implemented in the code.

    opened by leenamurgai 6
  • Is Reweighing doing what is expected to do?

    Is Reweighing doing what is expected to do?

    Hi,

    I noticed the reweighing mitigation algorithm is only learning 4 different sample weights (p/f, up/f, p/uf, up/uf):

    # reweighing weights
       self.w_p_fav = n_fav*n_p / (n*n_p_fav)
       self.w_p_unfav = n_unfav*n_p / (n*n_p_unfav)
       self.w_up_fav = n_fav*n_up / (n*n_up_fav)
       self.w_up_unfav = n_unfav*n_up / (n*n_up_unfav)
    

    is this the expected behavior?

    From the AIF360's documentation itself and when reviewing the cited papers, it seems like the appropriate behavior is to learn a separate weight for each group and class combination.

    Docs:

    Reweighing is a preprocessing technique that Weights the examples in each (group, label) combination differently to ensure fairness before classification

    Cited Paper: Screen Shot 2022-12-29 at 2 54 25 PM

    Screen Shot 2022-12-29 at 2 54 37 PM

    opened by salimnoma 5
  • NotImplementedError in standard dataset

    NotImplementedError in standard dataset

    Related to #109. Previously it warned Returning an ndarray, but in the future this will raise a 'NotImplementedError'. but now it returns the following error:

    NotImplementedError                       Traceback (most recent call last)
    <ipython-input-3-3996a519ec26> in <module>()
          1 from aif360.datasets import AdultDataset
    ----> 2 data = AdultDataset()
    
    /Users/staceyro/anaconda/envs/aif360/lib/python3.7/site-packages/aif360/datasets/adult_dataset.py in __init__(self, label_name, favorable_classes, protected_attribute_names, privileged_classes, instance_weights_name, categorical_features, features_to_keep, features_to_drop, na_values, custom_preprocessing, metadata)
        110             features_to_keep=features_to_keep,
        111             features_to_drop=features_to_drop, na_values=na_values,
    --> 112             custom_preprocessing=custom_preprocessing, metadata=metadata)
    
    /Users/staceyro/anaconda/envs/aif360/lib/python3.7/site-packages/aif360/datasets/standard_dataset.py in __init__(self, df, label_name, favorable_classes, protected_attribute_names, privileged_classes, instance_weights_name, scores_name, categorical_features, features_to_keep, features_to_drop, na_values, custom_preprocessing, metadata)
        119             else:
        120                 # find all instances which match any of the attribute values
    --> 121                 priv = np.logical_or.reduce(np.equal.outer(vals, df[attr]))
        122                 df.loc[priv, attr] = privileged_values[0]
        123                 df.loc[~priv, attr] = unprivileged_values[0]
    
    /Users/staceyro/anaconda/envs/aif360/lib/python3.7/site-packages/pandas/core/series.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs)
        703             return None
        704         else:
    --> 705             return construct_return(result)
        706 
        707     def __array__(self, dtype=None) -> np.ndarray:
    
    /Users/staceyro/anaconda/envs/aif360/lib/python3.7/site-packages/pandas/core/series.py in construct_return(result)
        692                 if method == "outer":
        693                     # GH#27198
    --> 694                     raise NotImplementedError
        695                 return result
        696             return self._constructor(result, index=index, name=name, copy=False)
    
    NotImplementedError: 
    

    Python: 3.7.2 Pandas: 1.0.3 AIF360: 0.2.3 (built from source)

    To replicate:

    import aif360
    from aif360.datasets import AdultDataset
    data = AdultDataset()
    
    opened by srnghn 5
  • Pre-processing for adult, german and compas dataset

    Pre-processing for adult, german and compas dataset

    I am trying to use AIF360 tool in one of my projects. I have facing problem in understanding the purpose of pre-processing, say, german credit dataset as described in the file AIF360/aif360/algorithms/preprocessing/optim_preproc_helpers/data_preproc_functions.py. Why is the custom processing described here needed in several algorithms like optimum pre-processing, meta classifier, reject classification. On the other hand, several algorithms do not require this for eg. adversarial debiasing, disparate impact remover, reweighing. Can you please help me understand the purpose?

    Thank you.

    opened by vsahil 5
  • Define xrange in python3

    Define xrange in python3

    xrange(i) was removed in Python 3 in favor of range(i) so for small values of i, use range() in both versions of Python and for larger values of i, define xrange() in Python 3 to be identical to range().

    Also:

    • Add flake8 tests to Travis CI as discussed in #14
    • Rename typeError --> TypeError
    • from fadm.nb.cv2nb import CaldersVerwerTwoNaiveBayes in test_cv2nb.py
    opened by cclauss 5
  • Add detectors api

    Add detectors api

    Signed-off-by: Adebayo Oshingbesan [email protected]

    This pull request adds the new detectors api for extending mdss beyond binary classification

    opened by Adebayo-Oshingbesan 4
  • Contribution Guide

    Contribution Guide

    Expand the contribution guide and add a "Getting Started" page.

    Getting Started offers an overview of the API and how it relates to pandas/sklearn while the contribution guide explains all the different parts of the repository from a developer perspective.

    opened by hoffmansc 0
  • Missing MulticlassLabelDataset Import

    Missing MulticlassLabelDataset Import

    By chance, I discovered the MulticlassLabelDataset (added via #165 ) in the code base but as it cannot be imported, I assume the __init__.py file lacks the following line from aif360.datasets.multiclass_label_dataset import MulticlassLabelDataset. Besides, it would be nice to have the class included in the documentation 😉

    opened by najann 0
  • Which source can I get functorch~=0.1.1 from?

    Which source can I get functorch~=0.1.1 from?

    (py37tf1) PS D:\PycharmProjects\test\AIF360> pip3 install --editable '.[all]' Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Obtaining file:///D:/PycharmProjects/test/AIF360 Preparing metadata (setup.py) ... done Requirement already satisfied: numpy>=1.16 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.21.5) Requirement already satisfied: scipy>=1.2.0 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.7.3) Requirement already satisfied: pandas>=0.24.0 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.3.5) Requirement already satisfied: scikit-learn>=1.0 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.0.2) Requirement already satisfied: matplotlib in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (3.5.3) Collecting jinja2<3.1.0 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/20/9a/e5d9ec41927401e41aea8af6d16e78b5e612bca4699d417f646a9610a076/Jinja2-3.0.3-py3-none-any.whl (133 kB) Collecting sphinx_rtd_theme Using cached https://pypi.tuna.tsinghua.edu.cn/packages/35/d0/e3b9b03bb6d253033d4d5b0855da6f5c3ed0000652710ed1bd80c72704a9/sphinx_rtd_theme-1.1.1-py2.py3-none-any.whl (2.8 MB) Collecting inFairness>=0.2.2 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b5/a2/f69c17d7c53a435031eb0fd6cbb83323ac2022fd2a207ff53aa57f9900a0/inFairness-0.2.2-py3-none-any.whl (38 kB) Collecting pytest>=3.5 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/67/68/a5eb36c3a8540594b6035e6cdae40c1ef1b6a2bfacbecc3d1a544583c078/pytest-7.2.0-py3-none-any.whl (316 kB) Collecting adversarial-robustness-toolbox>=1.0.0 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/35/dd/14079fae54e636197689e2e0b7cd3e4b6c2598481a900be9d20b44e7ac9c/adversarial_robustness_toolbox-1.12.2-py3-none-any.whl (1.4 MB) Collecting pytest-cov>=2.8.1 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fe/1f/9ec0ddd33bd2b37d6ec50bb39155bca4fe7085fa78b3b434c05459a860e3/pytest_cov-4.0.0-py3-none-any.whl (21 kB) Collecting lime Using cached lime-0.2.0.1-py3-none-any.whl Collecting tqdm Using cached https://pypi.tuna.tsinghua.edu.cn/packages/47/bb/849011636c4da2e44f1253cd927cfb20ada4374d8b3a4e425416e84900cc/tqdm-4.64.1-py2.py3-none-any.whl (78 kB) Requirement already satisfied: igraph[plotting] in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (0.10.2) Requirement already satisfied: cvxpy>=1.0 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.2.1) Collecting fairlearn~=0.7 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f9/22/93697472801e44344b5f7c3653762c4a143774f62b2a8bf97e7e7b1f7afa/fairlearn-0.7.0-py3-none-any.whl (177 kB) Collecting rpy2 Using cached rpy2-3.5.6-py3-none-any.whl Collecting seaborn Using cached https://pypi.tuna.tsinghua.edu.cn/packages/77/18/7354cb68dd7906d5a3118e0ed3e30c37502f9e6253139ecfcf4fa33af210/seaborn-0.12.1-py3-none-any.whl (288 kB) Requirement already satisfied: torch in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.13.0) Collecting ipympl Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2b/9d/33e2e196ecf80b385260301927bfe238b18af3f92a52e4317be330690663/ipympl-0.9.2-py2.py3-none-any.whl (510 kB) Collecting lightgbm Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e6/83/90f79ea1cf142353cbffda1e63c3cea8728b2cb1df0be93528e27cba19fd/lightgbm-3.3.3-py3-none-win_amd64.whl (1.0 MB) Collecting BlackBoxAuditing Using cached BlackBoxAuditing-0.1.54-py2.py3-none-any.whl Collecting tempeh Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/1b/d016f8d2ac250b7df50ffb630c3f71371d35ac92deb80653b0e4d2f9c1a9/tempeh-0.1.12-py3-none-any.whl (39 kB) Collecting skorch Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ef/a3/2b9f62d076d5d1c16ba65f4138cb11af12f87a0dc9301d80ce86423ab990/skorch-0.12.1-py3-none-any.whl (193 kB) Collecting jupyter Using cached https://pypi.tuna.tsinghua.edu.cn/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB) Collecting sphinx<2 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c7/da/e1b65da61267aeb92a76b6b6752430bcc076d98b723687929eb3d2e0d128/Sphinx-1.8.6-py2.py3-none-any.whl (3.1 MB) Requirement already satisfied: tensorflow>=1.13.1 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from aif360==0.5.0) (1.13.1) Requirement already satisfied: setuptools in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from adversarial-robustness-toolbox>=1.0.0->aif360==0.5.0) (65.5.0) Requirement already satisfied: six in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from adversarial-robustness-toolbox>=1.0.0->aif360==0.5.0) (1.16.0) Requirement already satisfied: osqp>=0.4.1 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from cvxpy>=1.0->aif360==0.5.0) (0.6.2.post0) Requirement already satisfied: scs>=1.1.6 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from cvxpy>=1.0->aif360==0.5.0) (3.2.0) Requirement already satisfied: ecos>=2 in c:\programdata\anaconda3\envs\py37tf1\lib\site-packages (from cvxpy>=1.0->aif360==0.5.0) (2.0.10) Collecting numpy>=1.16 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/97/9f/da37cc4a188a1d5d203d65ab28d6504e17594b5342e0c1dc5610ee6f4535/numpy-1.21.6-cp37-cp37m-win_amd64.whl (14.0 MB) INFO: pip is looking at multiple versions of to determine which version is compatible with other requirements. This could take a while. INFO: pip is looking at multiple versions of fairlearn to determine which version is compatible with other requirements. This could take a while. INFO: pip is looking at multiple versions of cvxpy to determine which version is compatible with other requirements. This could take a while. Collecting cvxpy>=1.0 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/94/5e/ccb689bd30bff55810234cd6c9247b443d7472d477255767f96d1c0b60b5/cvxpy-1.2.2-cp37-cp37m-win_amd64.whl (834 kB) INFO: pip is looking at multiple versions of adversarial-robustness-toolbox to determine which version is compatible with other requirements. This could take a while. Collecting adversarial-robustness-toolbox>=1.0.0 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2a/49/91ae4958239cac20eb4d78b57e734ebb549f8ac785460df482544e870bb0/adversarial_robustness_toolbox-1.12.1-py3-none-any.whl (1.4 MB) INFO: pip is looking at multiple versions of aif360[all] to determine which version is compatible with other requirements. This could take a while. ERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.8; 0.2.0 Requires-Python >=3.8; 0.2.1 Requires-Python >=3.8; 0.8.0 Requires-Python >=3.8; 0.8.0.dev0 Requires-Python >=3.8; 1.22.0 Requires-Python >=3.8; 1.22.0rc1 Requires-Python >=3.8; 1.22.0rc2 Requires-Python >=3.8; 1.22.0rc3 Requires-Python >=3.8; 1.22.1 Requires-Python >=3.8; 1.22.2 Requires-Python >=3.8; 1.22.3 Requires-Python >=3.8; 1.22.4 Requires-Python >=3.8; 1.23.0 Requires-Python >=3.8; 1.23.0rc1 Requires-Python >=3.8; 1.23.0rc2 Requires-Python >=3.8; 1.23.0rc3 Requires-Python >=3.8; 1.23.1 Requires-Python >=3.8; 1.23.2 Requires-Python >=3.8; 1.23.3 Requires-Python >=3.8; 1.23.4 Requires-Python >=3.8; 1.23.5 Requires-Python >=3.8; 1.24.0rc1 Requires-Python >=3.8; 1.24.0rc2 Requires-Python >=3.8; 6.0.0b1 Requires-Python >=3.8; 6.0.0b2 Requires-Python >=3.8 ERROR: Could not find a version that satisfies the requirement functorch~=0.1.1 (from infairness) (from versions: 0.2.0, 0.2.1, 1.13.0) ERROR: No matching distribution found for functorch~=0.1.1


    Which source can i get functorcfh~=0.1.1? Is this necessary?

    opened by wangzh1998 0
  • AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

    AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

    There is a problem in the file aif360/sklearn/preprocessing/learning_fair_representations.py:167 the function scipy.optimize.minimize returns a OptimizeResult which has the attribute message which is already a str object. So the program will file with:

    AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

    Quite a constructed example but this does fail with the error code above. I use aif360==0.5.0 and tried scipy==1.8.1, scipy==1.9.0 and scipy==1.9.1. Fix is trivial just change:

    warnings.warn('lbfgs failed to converge: {}'.format(
                  res.message.decode()), ConvergenceWarning)
    

    to

    warnings.warn('lbfgs failed to converge: {}'.format(
                  res.message), ConvergenceWarning)
    
    from aif360.sklearn.preprocessing import LearnedFairRepresentations
    import pandas as pd
    
    x = pd.DataFrame(
        [[1, 0.030671, -1.063611, 1.134739,  0.148453],
        [1, 0.837109, -1.008707, 1.134739,  -0.145920],
        [1, -0.042642, 0.245079, -0.420060, -0.145920],
        [1, 1.057047,  0.425801, -1.197459, -0.145920],
        [1, 0.775768,  1.408176, 1.134739,  -0.145920],
        [1, -0.115955, 0.898201, 1.523438,  -0.145920],
        [1, 0.763796, -0.280358, -1.974858, -0.145920],
        [1, 0.983734,  0.188195, -0.420060, -0.145920],
        [1, -0.555830,-1.364279, 1.523438,  1.761142],
        [1, 0.250608, -0.287350, 1.134739,  0.555214]],
        columns=["sex", "1", "2", "3", "4"]
    )
    x.set_index("sex", inplace=True)
    y = pd.DataFrame([0, 0, 0, 0, 0, 0, 0, 1, 1, 1])
    
    model = LearnedFairRepresentations(
        n_prototypes=5,
        reconstruct_weight=1,
        target_weight=1,
        fairness_weight=1,
        verbose=2,
        prot_attr='sex'
    )
    
    model.fit(x, y, priv_group=1)
    
    opened by makoeppel 0
  • Broken load_preproc_data_adult

    Broken load_preproc_data_adult

    Running the following code gives me:

    from aif360.algorithms.preprocessing.optim_preproc_helpers.data_preproc_functions import load_preproc_data_adult
    
    # Get the dataset and split into train and test
    dataset_orig = load_preproc_data_adult()
    
    Traceback (most recent call last):
      File "/home/makoeppel/ranking/combined_project/notebooks/test.py", line 4, in <module>
        dataset_orig = load_preproc_data_adult()
      File "/home/makoeppel/.local/lib/python3.10/site-packages/aif360/algorithms/preprocessing/optim_preproc_helpers/data_preproc_functions.py", line 77, in load_preproc_data_adult
        return AdultDataset(
      File "/home/makoeppel/.local/lib/python3.10/site-packages/aif360/datasets/adult_dataset.py", line 107, in __init__
        super(AdultDataset, self).__init__(df=df, label_name=label_name,
      File "/home/makoeppel/.local/lib/python3.10/site-packages/aif360/datasets/standard_dataset.py", line 85, in __init__
        df = custom_preprocessing(df)
      File "/home/makoeppel/.local/lib/python3.10/site-packages/aif360/algorithms/preprocessing/optim_preproc_helpers/data_preproc_functions.py", line 13, in custom_preprocessing
        df['Age (decade)'] = df['age'].apply(lambda x: x//10*10)
      File "/home/makoeppel/.local/lib/python3.10/site-packages/pandas/core/series.py", line 4433, in apply
        return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
      File "/home/makoeppel/.local/lib/python3.10/site-packages/pandas/core/apply.py", line 1088, in apply
        return self.apply_standard()
      File "/home/makoeppel/.local/lib/python3.10/site-packages/pandas/core/apply.py", line 1143, in apply_standard
        mapped = lib.map_infer(
      File "pandas/_libs/lib.pyx", line 2870, in pandas._libs.lib.map_infer
      File "/home/makoeppel/.local/lib/python3.10/site-packages/aif360/algorithms/preprocessing/optim_preproc_helpers/data_preproc_functions.py", line 13, in <lambda>
        df['Age (decade)'] = df['age'].apply(lambda x: x//10*10)
    TypeError: unsupported operand type(s) for //: 'str' and 'int'
    

    My env:

    aif360==0.5.0
    

    Downloaded the datasets from:

    1. adult.data
    2. adult.test
    3. adult.names
    opened by makoeppel 0
Releases(v0.5.0)
  • v0.5.0(Sep 3, 2022)

    AIF360 v0.5.0 Release Notes

    Highlights

    • New algorithms:
      • FairAdapt
    • New metrics:
      • MDSS
      • class_imbalance, kl_divergence, conditional_demographic_disparity
      • intersection and one_vs_rest meta-metrics
    • sklearn-compatible ports:
      • differential fairness metrics
      • MEPS, COMPAS violent
      • RejectOptionClassification, LearnedFairRepresentations

    New Features/Improvements

    • Multidimensional subset scanning (MDSS) for bias in classifiers by @Viktour19 in https://github.com/Trusted-AI/AIF360/pull/238
    • Update component.yaml to kfp v2 sdk by @yhwang in https://github.com/Trusted-AI/AIF360/pull/259
    • Fairadapt inclusion in AIF360 by @dplecko in https://github.com/Trusted-AI/AIF360/pull/257
    • Added a tutorial for advertising data by @barvek in https://github.com/Trusted-AI/AIF360/pull/310
    • More sklearn-compatible algorithms by @hoffmansc in https://github.com/Trusted-AI/AIF360/pull/318
    • Dataset Improvements by @hoffmansc in https://github.com/Trusted-AI/AIF360/pull/278
      • array of sample-wise protected attributes may now be passed in prot_attr instead of an index label
    • Method of the month (July) by @hoffmansc in https://github.com/Trusted-AI/AIF360/pull/324
    • sklearn-compat additions by @mnagired in https://github.com/Trusted-AI/AIF360/pull/322
      • add predict_proba to RejectOptionClassifier
    • More sklearn-compatible metrics by @hoffmansc in https://github.com/Trusted-AI/AIF360/pull/290
      • smoothed_edf, df_bias_amplification
      • class_imbalance, kl_divergence, conditional_demographic_disparity
      • intersection, one_vs_rest

    Backwards-Incompatible Changes

    • Add detectors api by @Adebayo-Oshingbesan in https://github.com/Trusted-AI/AIF360/pull/305
      • version of bias_scan in aif360.metrics to be deprecated next release

    Fixes

    • Fixed computation of coefficient of variation in classification_metrics by @plankington in https://github.com/Trusted-AI/AIF360/pull/288
    • Fix exponential gradient reduction without protected attribute (#267) by @jdnklau in https://github.com/Trusted-AI/AIF360/pull/268
    • Remove caches due to excessive memory use by @Adebayo-Oshingbesan in https://github.com/Trusted-AI/AIF360/pull/317
    • fix rpy2 crash bug by @hoffmansc in https://github.com/Trusted-AI/AIF360/pull/313
    • Fix pipelining bug in fairlearn algorithms by @hoffmansc in https://github.com/Trusted-AI/AIF360/pull/323
    • Optional tempeh, conditional imports by @DanielRyszkaIBM in https://github.com/Trusted-AI/AIF360/pull/338
    • Restricting AdversarialDebiasing's trainable variables to current scope by @mfeffer in https://github.com/Trusted-AI/AIF360/pull/255
    • Increasing max_iter to 1000 for LogisticRegression used in PrejudiceRemover by @mfeffer in https://github.com/Trusted-AI/AIF360/pull/254

    New Contributors

    • @Viktour19 made their first contribution in https://github.com/Trusted-AI/AIF360/pull/238
    • @jdnklau made their first contribution in https://github.com/Trusted-AI/AIF360/pull/268
    • @yhwang made their first contribution in https://github.com/Trusted-AI/AIF360/pull/259
    • @dplecko made their first contribution in https://github.com/Trusted-AI/AIF360/pull/257
    • @plankington made their first contribution in https://github.com/Trusted-AI/AIF360/pull/288
    • @Adebayo-Oshingbesan made their first contribution in https://github.com/Trusted-AI/AIF360/pull/305
    • @barvek made their first contribution in https://github.com/Trusted-AI/AIF360/pull/310
    • @milevavantuyl made their first contribution in https://github.com/Trusted-AI/AIF360/pull/309
    • @josue-rodriguez made their first contribution in https://github.com/Trusted-AI/AIF360/pull/315
    • @DanielRyszkaIBM made their first contribution in https://github.com/Trusted-AI/AIF360/pull/338
    • @mnagired made their first contribution in https://github.com/Trusted-AI/AIF360/pull/322
    • @mfeffer made their first contribution in https://github.com/Trusted-AI/AIF360/pull/255

    Full Changelog: https://github.com/Trusted-AI/AIF360/compare/v0.4.0...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Mar 4, 2021)

    AIF360 v0.4.0 Release Notes

    This is a major release containing a number of new features, improvements, and bugfixes.

    Highlights

    • TensorFlow 2, Python 3.8 now supported
    • New algorithms:
      • Exponentiated Gradient Reduction
      • Grid Search Reduction
    • New dataset:
      • Law school GPA

    New Features/Improvements

    • Python 3.8 and TensorFlow 2 (via compat.v1) support added (#230)
    • Algorithms from fairlearn added (#215):
      • Exponentiated Gradient Reduction and Grid Search Reduction
      • Support for regression datasets
      • Law school GPA dataset added
    • MetaFairClassifier code cleaned and sped up (#196)
    • removed numba dependency (#187)
    • maxiter and maxfun arguments in LFR fit() (#184)

    Backwards-Incompatible Changes

    • Removed support for Python 3.5

    Fixes

    • Fix bug where scores in a single-row dataset was getting squeezed (#193)
    • Typo in consistency_score documentation (#195)
    • Lime notebook license issue (#191)

    New Contributors

    @baba-mpe, @SSaishruthi, @leenamurgai, @synapticarbors, @sohiniu, @yangky11

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jun 2, 2020)

    AIF360 v0.3.0 Release Notes

    This is a major release containing a number of new features, improvements, and bugfixes.

    Highlights

    New Features/Improvements

    • Optional dependencies may now be installed using the setuptools "extras" option: e.g., pip install 'aif360[LFR,AdversarialDebiasing]' or pip install 'aif360[all]'
    • Added support for integrations with MLOps (Kubeflow and NiFi) and examples
    • Added scores output to AdversarialDebiasing.predict() (#139)
    • Added a subset() method to StructuredDataset (#140)
    • Added new MulticlassLabelDataset to support basic multiclass problems (#165)
    • scikit-learn compatibility (#134)

      • EXPERIMENTAL: incomplete, contributions welcome
      • 4 datasets (Adult, German, Bank, Compas) in DataFrame format with protected attributes in the index
        • Automatically downloads from openml.org
      • 6 group fairness metrics as functions (statistical_parity_difference, disparate_impact_ratio, equal_opportunity_difference, average_odds_difference, average_odds_error, between_group_generalized_entropy_error)
      • 2 individual fairness metrics as functions (generalized_entropy_index and its variants, consistency_score)
      • 5 additional metrics as functions (specificity_score, base_rate, selection_rate, generalized_fpr, generalized_fnr)
      • make_scorer function to wrap metrics for use in sklearn cross-validation functions (#174, #178)
      • 3 algorithms (Reweighing, AdversarialDebiasing, CalibratedEqualizedOdds)

    Fixes

    • Fixed deprecation warning/NotImplementedError in StandardDataset (#115)
    • Fixed age threshold in GermanDataset (#129 and #137)
    • Corrected privileged/unprivileged attribute values for COMPAS dataset in some demos (#138)
    • Fixed base rate computation in EqOddsPostprocessing (#170)
    • Improved warning messages when missing optional packages (#170)
    • Multiple documentation fixes (#114, #124, #153, #155, #157, #158, #159, #170)

    New Contributors

    @autoih, @romeokienzler, @jimbudarz, @stephanNorsten, @sethneel, @imolloy, @guillemarsan, @gdequeiroz, @chajath, @bhavyaghai, @Tomcli, @swapna-somineni, @chkoar, @motapaolla

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0rc0(Apr 3, 2020)

    AIF360 v0.3.0rc0 Release Notes

    This is a major release containing a number of new features, improvements, and bugfixes.

    Highlights

    New Features/Improvements

    • Optional dependencies may now be installed using the setuptools "extras" option: e.g., pip install 'aif360[LFR,AdversarialDebiasing]' or pip install 'aif360[all]'
    • Added support for integrations with MLOps (Kubeflow and NiFi) and examples
    • Added scores output to AdversarialDebiasing.predict() (#139)
    • Added a subset() method to StructuredDataset (#140)
    • scikit-learn compatibility (#134)

      • EXPERIMENTAL: incomplete, contributions welcome
      • 4 datasets (Adult, German, Bank, Compas) in DataFrame format with protected attributes in the index
        • Automatically downloads from openml.org
      • 6 group fairness metrics as functions (statistical_parity_difference, disparate_impact_ratio, equal_opportunity_difference, average_odds_difference, average_odds_error, between_group_generalized_entropy_error)
      • 2 individual fairness metrics as functions (generalized_entropy_index and its variants, consistency_score)
      • 5 additional metrics as functions (specificity_score, base_rate, selection_rate, generalized_fpr, generalized_fnr)
      • 3 algorithms (Reweighing, AdversarialDebiasing, CalibratedEqualizedOdds)

    Fixes

    • Fixed deprecation warning/NotImplementedError in StandardDataset (#115)
    • Fixed age threshold in GermanDataset (#129 and #137)
    • Corrected privileged/unprivileged attribute values for COMPAS dataset in some demos (#138)
    • Multiple documentation fixes (#114, #124, #153, #155, #157, #158, #159)

    New Contributors

    @autoih, @romeokienzler, @jimbudarz, @stephanNorsten, @sethneel, @imolloy, @guillemarsan, @gdequeiroz, @chajath, @bhavyaghai, @Tomcli

    Source code(tar.gz)
    Source code(zip)
  • v0.2.3(Mar 9, 2020)

    AIF360 v0.2.3 Release Notes

    Fixes

    • Fixed fit_predict arguments in RejectOptionClassification (#111)
    • Removed Orange3 from requirements (#113)
    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Sep 16, 2019)

    AIF360 v0.2.2 Release Notes

    Fixes

    • Removed Gender Classification tutorial (see #101 for details and discussion)
    • Bug fix in Optimized Preprocessing to check for optimality correctly
    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Aug 13, 2019)

  • v0.2.0(Jan 23, 2019)

    AIF360 v0.2.0 Release Notes

    Highlights

    New Algorithm:

    New Features/Improvements

    • Added download script for MEPS data
    • Added ability to choose protected attribute for DisparateImpactRemover
    • Updated OptimPreproc to use the latest version of cvxpy
    • Added a threshold value to update labels from predicted scores in CalibratedEqOddsPostprocessing
    • New scores_names arg in StructuredDataset allows for easier importing of predictions run elsewhere
    • tutorial_gender_classification notebook now uses skimage instead of cv2
    • aif360.__version__ now returns the correct version string

    Fixes

    • Changed Credit Scoring Tutorial to use Reweighing; added new demo using AdversarialDebiasing on Adult Dataset
    • Removed dependency on subprocess.run in PrejudiceRemover for Python 2.7 compatibility
    • Fixed bug where categorical_features would not take into account features_to_drop in StandardDataset

    New Contributors

    @ckadner, @cclauss, @vijaykeswani, @ffosilva, @kant, @adrinjalali, @mariaborbones

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Sep 18, 2018)

  • v0.1.0(Sep 18, 2018)

    AIF360 0.1.0 Release Notes

    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.

    Highlights

    A brief list of features provided in this release include:

    Source code(tar.gz)
    Source code(zip)
Owner
This GitHub org hosts LF AI Foundation projects in the category of Trusted and Responsible AI.
null
LibRerank is a toolkit for re-ranking algorithms. There are a number of re-ranking algorithms, such as PRM, DLCM, GSF, miDNN, SetRank, EGRerank, Seq2Slate.

LibRerank LibRerank is a toolkit for re-ranking algorithms. There are a number of re-ranking algorithms, such as PRM, DLCM, GSF, miDNN, SetRank, EGRer

null 126 Dec 28, 2022
Uber Open Source 1.6k Dec 31, 2022
Covid-polygraph - a set of Machine Learning-driven fact-checking tools

Covid-polygraph, a set of Machine Learning-driven fact-checking tools that aim to address the issue of misleading information related to COVID-19.

null 1 Apr 22, 2022
LibTraffic is a unified, flexible and comprehensive traffic prediction library based on PyTorch

LibTraffic is a unified, flexible and comprehensive traffic prediction library, which provides researchers with a credibly experimental tool and a convenient development framework. Our library is implemented based on PyTorch, and includes all the necessary steps or components related to traffic prediction into a systematic pipeline.

null 432 Jan 5, 2023
Uplift modeling and causal inference with machine learning algorithms

Disclaimer This project is stable and being incubated for long-term support. It may contain new experimental code, for which APIs are subject to chang

Uber Open Source 3.7k Jan 7, 2023
A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

Light Gradient Boosting Machine LightGBM is a gradient boosting framework that uses tree based learning algorithms. It is designed to be distributed a

Microsoft 14.5k Jan 7, 2023
Machine Learning Algorithms

Machine-Learning-Algorithms In this project, the dataset was created through a survey opened on Google forms. The purpose of the form is to find the p

Göktuğ Ayar 3 Aug 10, 2022
Machine learning algorithms implementation

Machine learning algorithms implementation This repository consisits of implementation of various machine learning algorithms. The algorithms implemen

Karun Dawadi 1 Jan 3, 2022
Machine Learning Algorithms ( Desion Tree, XG Boost, Random Forest )

implementation of machine learning Algorithms such as decision tree and random forest and xgboost on darasets then compare results for each and implement ant colony and genetic algorithms on tsp map, play blackjack game and robot in grid world and evaluate reward for it

Mohamadreza Rezaei 1 Jan 19, 2022
Interactive Web App with Streamlit and Scikit-learn that applies different Classification algorithms to popular datasets

Interactive Web App with Streamlit and Scikit-learn that applies different Classification algorithms to popular datasets Datasets Used: Iris dataset,

Samrat Mitra 2 Nov 18, 2021
A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.

Master status: Development status: Package information: TPOT stands for Tree-based Pipeline Optimization Tool. Consider TPOT your Data Science Assista

Epistasis Lab at UPenn 8.9k Jan 9, 2023
Python Extreme Learning Machine (ELM) is a machine learning technique used for classification/regression tasks.

Python Extreme Learning Machine (ELM) Python Extreme Learning Machine (ELM) is a machine learning technique used for classification/regression tasks.

Augusto Almeida 84 Nov 25, 2022
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques

Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

Vowpal Wabbit 8.1k Dec 30, 2022
CD) in machine learning projectsImplementing continuous integration & delivery (CI/CD) in machine learning projects

CML with cloud compute This repository contains a sample project using CML with Terraform (via the cml-runner function) to launch an AWS EC2 instance

Iterative 19 Oct 3, 2022
Meerkat provides fast and flexible data structures for working with complex machine learning datasets.

Meerkat makes it easier for ML practitioners to interact with high-dimensional, multi-modal data. It provides simple abstractions for data inspection, model evaluation and model training supported by efficient and robust IO under the hood.

Robustness Gym 115 Dec 12, 2022
A Python Package to Tackle the Curse of Imbalanced Datasets in Machine Learning

imbalanced-learn imbalanced-learn is a python package offering a number of re-sampling techniques commonly used in datasets showing strong between-cla

null 6.2k Jan 1, 2023
PLUR is a collection of source code datasets suitable for graph-based machine learning.

PLUR (Programming-Language Understanding and Repair) is a collection of source code datasets suitable for graph-based machine learning. We provide scripts for downloading, processing, and loading the datasets. This is done by offering a unified API and data structures for all datasets.

Google Research 76 Nov 25, 2022
A collection of interactive machine-learning experiments: 🏋️models training + 🎨models demo

?? Interactive Machine Learning experiments: ??️models training + ??models demo

Oleksii Trekhleb 1.4k Jan 6, 2023
MIT-Machine Learning with Python–From Linear Models to Deep Learning

MIT-Machine Learning with Python–From Linear Models to Deep Learning | One of the 5 courses in MIT MicroMasters in Statistics & Data Science Welcome t

null 2 Aug 23, 2022