Is my AI model biased? — A brief overview of AI Fairness

Rajat Roy
3 min readJun 13, 2022
Photo by Elisa Ventur on Unsplash

Introduction

One fine evening, I was working on training of a loan amount prediction model. It’s a regression problem where we give out point predictions in terms of loan amount that could be granted to a particular applicant. After successful experimentation in the training process, I ended up with a model that with an acceptable performance the mean square error was around 30.

But, when I tested the model on new unseen data I suddenly observed one thing that there was definitely a model bias happening due to which the prediction range was different for each gender.

Imagine putting this model in production.

We usually encounter model bias while training a ML model and there are some openly available techniques which can help mitigate it.

Bias vs Fairness

Model bias is generated due to some erroneous assumption made by the ML model during its decision making. In general terms, bias would mean making a typical prediction for/against a particular individual or group.

Bias can be introduced at any stage during modelling process, be it data collection, data cleaning, feature engineering, model training or model testing. It is important to inspect, monitor, assess, investigate, and evaluate at each and every stage.

Fairness refers to the lack of bias towards a person or group based on their attributes. Bias is discrimination toward or against a specific individual or group.

Example of minor vs major entity in a group

How to mitigate model bias?

Let’s discuss about the different ways through which we can reduce bias from any ML model.

i. Disparate impact: Suppose there are two groups and our model is bias towards one group. So, definitely the bias group must be getting some positive outcome compared to the other one. Disparate impact is calculated as the ratio between positive outcomes within each groups.

To reduce the impact of disparity, we can use a pre-processing technique known as Disparity Impact Remover.

ii. Adversarial debiasing: This is a technique which is performed during model training. Basically, we train two models. One model tries to learn from the features and the actual target. The second model or adversarial model tries to learn from the original features but the targets are taken from the predictions of the first model. The adversarial model will fail to perform well on the sensitive attributes and that’s how we would be able to detect bias in our first model.

iii. Equalized Odds: It is a post-processing approach in which a classifier handles each group the same way if they have the same error rates.

Handling bias using Python

There are some libraries available in python which can help with reducing bias.

i. FairLearn: We can use FairLearn which is a python library to calculate metrics like accuracy, precision etc. based on sensitive features like gender. It also has a reduction module through which we can reduce demographic parity. More details about FairLearn can be found here.

ii. AI Fairness 360: AIF 360 is originally developed by IBM and we can use it for mitigating bias from any ML model. So, there are different stages at which we can introduce model processing to make the model fairer. The different stages are pre-processing, in-processing and post-processing. Explore about different methods of model processing through AIF 360 here.

References

I would like to thank the authors of the following blog posts for writing about fairness in AI and I request you to go through these links once.

  1. 5 reasons your model is making unfair predictions

2. AI Fairness — Explanation of Disparate Impact Remover

3. Using Adversarial Debiasing to Reduce Model Bias

4. Measuring Fairness in Machine Learning Models

--

--

Rajat Roy

Data Scientist | Machine Learning Engineer | Blogger