This video explains three key definitions of fairness in machine learning: Equal Opportunity (requiring equal True Positive Rates across protected groups), Equalized Odds (requiring both equal True Positive and False Positive Rates), and Disparate Impact (requiring the Positive Prediction Rate for unprivileged groups to be at least 80% of that for privileged groups). The video demonstrates how to apply these metrics using the Adult dataset to analyze loan approval fairness, showing that accuracy alone can hide unfairness while TPR and FPR reveal disparities in who benefits from model predictions.
Fairness Metrics in Machine Learning: Equal Opportunity & More
Added:take a look at these true positive rates for a model used to automatically give out loans they tell us 63.2 percent of males who should have been given loans were given loans however this figure is only 44.3 for females clearly this model is being unfair towards women in fact in using true positive rates in this way we are applying a definition of fairness called equal opportunity we'll explore this definition along with accuracy equalize odds and disparate impact this video Builds on another where we did an exploratory fairness analysis there we try to quantify characteristics in our data that could potentially lead to an unfair model now we're going to apply different definitions to understand if the model is actually unfair the idea is that you can link back to the Explorer poetry analysis so figure out what is causing the unfairness by the way if you want the python code for this analysis then check out the article Linked In the description also make sure to wait until the end of the video where I explain how you can get access to a python sharp course a package used to understand and explain your models so we've built a model using the adult data set after a bit of feature engineering we use the first six columns to train a model these are features like a person's level of education and marital status we want to use these to predict if a person's annual income is above or below fifty thousand dollars in algorithm fairness it is convention to reframe the target variable so that the positive prediction will lead to some benefits so we take above fifty thousand dollars as the positive prediction and Below 50 000 has the negative prediction if we predict that the person's income is about above 50 000 They will receive a loan otherwise they will not receive a loan in other words the positive prediction will lead to the benefits of receiving a loan another convention is to reformulate protected features as binary variables where one represents a privileged group and zero represents an unprivileged group so going forward or race will Define our protected features so that white is a privileged group for sex we'll Define it so that male is the privileged Group by splitting the population into groups we can compare model performance on these groups this is done using metrics based on the model's confusion Matrix which breaks down the number of correct and incorrect predictions for example false positives on the number of incorrect positive predictions made by the model in other words this is the number of people who the model predicted to make over 50 000 but who actually made under fifty thousand similarly true positives are the number of correct positive predictions true negatives and false negative negatives or the number of correct and incorrect negative predictions [Music] foreign this brings us to the first metric used to measure fairness accuracy actually we'll see that this is not always the best metric to use accuracy is the number of true negatives and true positives over the total number of observations in other words is the percentage of correct predictions yeah we have the accuracy of our model by the protected features or both protected features you can see that the accuracy is higher for the unprivileged group okay so what's the problem based on this it seems like the model is actually biased towards the privilege group the issue is that accuracy can hide the true consequences of a model remember a positive prediction will lead to the benefits of receiving a loan an incorrect positive prediction would decrease accuracy but those people would still be better off due to this mistake accuracy can be useful in explaining the general performance of a model but we still need metrics that capture the benefit resulting from model predictions one way to do this is to use the true positive rate or tpr the denominator is the number of actual positives in our data sets the numerator is the number of correctly predicted positives so the tpr is the percentage of actual positives that were correctly predicted as positive for our problem we can interpret this as the percentage of people who should have received loans and did receive loans or in other words this is the percentage of people who have rightfully benefited from the model here we have our models tpr for the privileged and unprivileged groups we can see that they are lower for the unprivileged groups meaning a smaller percentage of these groups have rightfully been benefited from the model we can go further by finding the tpr at the intersection of the protected features the tpr is even lower when the person is in both unprivileged groups in fact the tpr for white males is over 50 percent higher than for females of other races using tprs leads us to our first definition of fairness equal opportunity under this definition we consider a model to be fair if the tprs of the privileged and unprivileged groups are equal in practice we give some leeway for statistical uncertainty we can require the differences to be less than a certain cut-off for our analysis we have taken the ratio of unprivileged to privilege the ratio must be larger than some predefined percentage foreign tpr allows us to capture those who have rightfully benefited from a model but this is not the only way a person can benefit from model predictions we can also use false positive rates or FBI's to capture model benefits fpr is the number of incorrect positive predictions over the number of actual negatives this gives the percentage of people who should not have received loans but did receive loans so fpr gives the percentage of people who have wrongfully benefited from the model yeah you can see that fprs for our model these are higher for the privileged group this tells us that a higher percentage of males and a higher percentage of white people have received loans when they should not have received loans this leads us to our second definition of fairness equalized odds like with equal opportunity it requires that true positive rates are equal it also requires that false positive rates are equal this may means that equalized odds can be thought of as a stricter definition of fairness it requires that a similar percentage of the groups both rightfully and wrongfully benefits from model predictions foreign on to our last definition desperate impact we start by calculating the PPP rates this is the percentage of people who have been correctly or incorrectly predicted as positive for our problem we can interpret this as the percentage of people who have received loans you can see these rates for our model again these figures suggest that the model is unfair towards the unprivileged group that is a smaller percentage of them are benefiting from the model under disparate impact we consider a model to be fair if we have equal PPP rates again in practice we use a cut off to give some leeway in the United States there is a legal precedent to set this cut off at 80 percent that is the rate for the unprivileged group should not be less than 80 percent of the privileged group when using disparate impact we should consider one of its limitations that is it does not take ground truth into account let's consider the case of a model that only makes correct predictions we would have no false positives and the PPP rates would be equal to the percentage of actual positives in the population in some cases it would make sense to expect equal PPP rates for the privileged and unprivileged group for a automated recruitment model we would expect the model to predict an equal percentage of males and females to be high quality job candidates in other cases it doesn't make sense lighter skin is more susceptible to skin cancer and we would expect higher cancer rates for these people in this case a low disparate impact ratio would not be an indication of an unfair model so this brings us to the point that it's important to think about what definitions make sense for your problem we must also always interpret metrics in terms of the consequences faced by the people who interact with the model lastly we should consider the limitations of metrics in general fairness is a complicated issue it cannot necessarily be captured by a metric or even a collection of metrics as data scientists we need to accept this and look to approaches that go beyond data and models that being said based on the metrics that we've seen our model does seem to be unfair the question is why a good place to start is by going back to our initial exploratory analysis this can be used as the starting point for understanding the reasons for unfairness the next question is how can we correct the unfairness in a future video we'll explore both quantitative and non-quantitative approaches or if you want to read about these straight away I've linked to an article in the description related to fairness is the concept of interpretability if you want to understand and explain your models then look no further than the python sharp package my course will teach you both the theory and application of shap and for a limited time you can get free access if you sign up to the newsletter in the description
Up Next

Fairness in Machine Learning: Fairlearn Tutorial Guide
@pyladiesamsterdam
1.4K views•2021-11-25

Building Real-Time ML Pipelines with Feature Stores and MLOps Frameworks
@ODSCAI
5.1K views•2022-02-20

Shapley Values in Machine Learning: Feature Attribution
@adataodyssey
30.5K views•2023-04-03

Neural Networks Explained: Math, Layers, and Learning Fundamentals
@3blue1brown
21.9M views•2017-10-05
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Artificial Intelligence















![Estación Algorítmica: Claudia López [Procesos] Computación, desigualdad y mujeres](https://i.ytimg.com/vi/zdz4RBN0TsY/maxresdefault.jpg)























