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:
Either run locally:
then:
Clone the repo locally. In a terminal, run:
git clone https://github.com/IBM/ensure-loan-fairness-aif360
Start your Jupyter Notebook process. Running in the ensure-loan-fairness-aif360
cloned repo directory will help you find the notebook and the output as described below. The jupyter notebook
process will open your browser.
cd ensure-loan-fairness-aif360
jupyter notebook
Navigate to the notebooks
directory and open the notebook file named credit_scoring.ipynb
.
Log into IBM's Watson Studio. Once in, you'll land on the dashboard.
Create a new project by clicking + New project
and choosing Data Science
:
Enter a name for the project name and click Create
.
NOTE: By creating a project in Watson Studio a free tier Object Storage
service and Watson Machine Learning
service will be created in your IBM Cloud account. Select the Free
storage type to avoid fees.
Upon a successful project creation, you are taken to a dashboard view of your project. Take note of the Assets
and Settings
tabs, we'll be using them to associate our project with any external assets (datasets and notebooks) and any IBM cloud services.
From the new project Overview
panel, click + Add to project
on the top right and choose the Notebook
asset type.
Fill in the following information:
From URL
tab. [1]Name
for the notebook and optionally a description. [2]Notebook URL
provide the following url: https://raw.githubusercontent.com/IBM/ensure-loan-fairness-aif360/master/notebooks/credit_scoring.ipynb [3]Runtime
select the Python 3.5
option. [4]Click the Create
button.
TIP: Once successfully imported, the notebook should appear in the Notebooks
section of the Assets
tab.
Use the menu pull-down Cell > Run All
to run the notebook, or run the cells one at a time top-down using the play button.
As the cells run, watch the output for results or errors. A running cell will have a label like In [*]
. A completed cell will have a run sequence number instead of the asterisk.
See examples/example_notebook.ipynb
:
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.