Machine learning models can be used in critical applications, such as hiring processes, the judicial system, credit scoring, or facial recognition systems. In these cases, it is essential to ensure that the algorithms used do not discriminate against those they are assessing.
There have been a number of high-profile, real-world instances of AI systems displaying bias and materially impacting particular groups. A 2018 study, for example, found that three popular facial recognition systems appeared to be biased, and incorrectly classified up to 34.7% of Black women compared to a 0.8% error rate for white men.
In 2020, another study analysed facial recognition systems from different companies. The results showed that the models have high accuracy (over 90%), but this accuracy is not homogeneous, presenting a clear racial bias. The accuracy for people with darker skin was in fact up to one-third lower than for people with lighter skin.
The prevalence of AI in systems that have the potential to significantly impact people's lives means there is a genuine risk that the technology could reinforce existing social inequities if a conscious effort is not made to address these issues within machine learning.
With the use of artificial intelligence technologies now widespread, the field of responsible AI has become even more important. It is crucial that companies/researchers/individuals who use or build AI models take responsibility for the development of these systems. The first step? Understanding what bias is.
Bias can be understood in different ways. Generally, when we talk about biases in machine learning models, we are referring to the model's inability to capture the complexity of the data, i.e., a model that systematically makes incorrect predictions. In this case, a model with high bias has the characteristic of underfitting.
In the context of fair and responsible AI, we define bias as an unwanted prejudice in the decisions made by an AI system that is systematically disadvantageous to a person or group. There are various types of biases, and they can be inadvertently introduced into algorithms at any stage of the development process, whether during data generation or model construction.
To be able to measure whether a system treats different groups equally, we must agree on the following definitions of equality:
You can learn all about the different metrics for equality of outcomes and opportunities via the resources in the Holstic AI library.
Using the HolisticAI library, we can apply dozens of bias mitigation and measurement strategies for machine learning models for classification, regression, clustering, or recommendation systems. All these tasks can be applied using Python. Python is a popular programming language used extensively in data science/machine learning projects due to its simplicity, versatility, and robustness.
Python has a vast collection of libraries and frameworks that facilitate data analysis, data visualization, statistical modelling, and machine learning tasks. In this post we use three libraries: Holistic AI (responsible ai tasks), Scikit-Learn (machine learning models), and Matplotlib (data visualization).
In this introductory tutorial, we will address a specific case: bias mitigation in a classification task using the Exponentiated Gradient Reduction strategy.
In this example, we use the Adult Dataset. We start by loading the data and performing a simplified pre-processing to obtain two groups of interest based on gender: female and male. This way, we will be able to investigate and, if necessary, mitigate the existing bias between the two groups.
In the figure above we can see that the dataset is unbalanced, with a significantly larger representation of men and individuals belonging to the race attribute "white". This can lead to biased results and undermine the ability to generalise any findings or models trained with this data.
The “Reference” column shows what values each metric considers fair. For example, a Disparate Impact of 1 indicates that the results are fair and unbiased. Without the mitigator (Baseline), the metric result is 0.2960, far from what would be considered fair. Applying the mitigator reduces this value to 0.9712, meaning the result is fair.
The comparative result shows that the mitigation strategy was effective in mitigating the existing biases between groups A (female) and B (male).
Implementing techniques such as data preprocessing and fairness metrics can ensure that AI models do not perpetuate unfair biases against certain groups. Using Python's powerful libraries and frameworks, we can easily incorporate these steps into machine learning pipelines and automate the process of identifying and addressing bias in our models. As machine learning's role in our daily lives continues to increase, it is vital that we take steps to employ these safeguards to eliminate bias and create a fairer AI future.
To explore more techniques for measuring and mitigating bias, visit the Holistic AI library, an open-source resource designed to improve the trustworthiness and transparency of AI systems.
DISCLAIMER: This blog article is for informational purposes only. This blog article is not intended to, and does not, provide legal advice or a legal opinion. It is not a do-it-yourself guide to resolving legal issues or handling litigation. This blog article is not a substitute for experienced legal counsel and does not provide legal advice regarding any situation or employer.
Schedule a call with one of our experts