Chapter 3. Python Tutorial
This chapter introduces the basic functionality of AIF 360 to interested developers who might not have a background in bias detection and mitigation. It offers a Python tutorial on detecting and mitigating racial bias through the example of income estimation using the Optimized Pre-Processing algorithm. You can also find this tutorial on GitHub, where more sophisticated machine learning workflows are given in the author tutorials and demonstration notebooks.1
As these examples illustrate, a bias detection and/or mitigation toolkit needs to be tailored to the particular bias of interest. More specifically, it needs to know the attributes, called protected attributes, that are of interest: race is one example of a protected attribute; age is a second.
We will use the Adult Census Income dataset, splitting it into training and test datasets. We will look for bias in the creation of our machine learning model, which is intended to help decide whether an individual’s annual income should be set greater than $50,000, based on various personal attributes. The protected attribute will be race, with “1” (white) and “0” (not white) being the values for the privileged and unprivileged groups, respectively. For this first tutorial, we check for bias in the initial training data, mitigate the bias, and recheck.
Here are the steps involved:
-
Write import statements.
-
Set bias detection options, load dataset, and split between train and test.
-
Compute fairness metric ...
Get AI Fairness now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.