IBM / ensure-loan-fairness-aif360

A demonstration of the AI Fairness 360 toolbox for bias metrics, explanations, and remediation. Code Pattern: https://developer.ibm.com/patterns/ensuring-fairness-when-processing-loan-applications
Apache License 2.0
28 stars 25 forks source link
ai fairness ibm machine-learning open-source

Ensure Loan Fairness with AI Fairness 360

A machine learning model makes predictions of an outcome for a particular instance. (Given an instance of a loan application, predict if the applicant will repay the loan.) The model makes these predictions based on a training dataset, where many other instances (other loan applications) and actual outcomes (whether they repaid) are provided. Thus, a machine learning algorithm will attempt to find patterns, or generalizations, in the training dataset to use when a prediction for a new instance is needed. (For example, one pattern it might discover is "if a person has salary > USD 40K and has outstanding debt < USD 5, they will repay the loan".) In many domains this technique, called supervised machine learning, has worked very well.

However, sometimes the patterns that are found may not be desirable or may even be illegal. For example, a loan repay model may determine that age plays a significant role in the prediction of repayment because the training dataset happened to have better repayment for one age group than for another. This raises two problems: 1) the training dataset may not be representative of the true population of people of all age groups, and 2) even if it is representative, it is illegal to base any decision on a applicant's age, regardless of whether this is a good prediction based on historical data.

AI Fairness 360 is designed to help address this problem with fairness metrics and bias mitigators. Fairness metrics can be used to check for bias in machine learning workflows. Bias mitigators can be used to overcome bias in the workflow to produce a more fair outcome.

When the reader has completed this Code Pattern, they will understand how to:

Flow

architecture

  1. User interacts with Watson Studio to create a Jupyter notebook
  2. Notebook imports the AIF360 toolkit.
  3. Data is loaded into the notebook.
  4. User runs the notebook, which uses AIF360 tookit to assess fairness of Machine Learning model.

Included components

Steps

Either run locally:

  1. Clone the repo
  2. Load the notebook

or use Watson Studio:

  1. Create a new project
  2. Create the notebook

then:

  1. Run the notebook

Run locally

1. Clone the repo

Clone the repo locally. In a terminal, run:

git clone https://github.com/IBM/ensure-loan-fairness-aif360

2. Load the notebook

Use Watson Studio

1. Create a new project

2. Create the notebook

3. Run the notebook

Sample output

See examples/example_notebook.ipynb:

example output

Links

Learn more

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ