FOUNDATIONS OF MACHINE LEARNING

Course info

Course materials

FAQ

Course materials

/

Section

Fairness in Predicting Diabetes Progression


Introduction

In this example, we will revisit the diabetes data (Efron et. al., 2004) used in the second example in section 4 of the course. As a recap, the diabetes dataset consists of in total 442 observations with the following features: age, sex, BMI, average blood pressure and six different blood serum measurements. The target variable is numerical and describes the disease progression one year after the original measurements.

We will redefine the problem a bit from the previous exercise and recast the regression problem as a classification problem. We split the observations into two classes based on the target variable, where the severe progression class has a disease progression larger than 140 and the mild progression class has a disease progression that is at most 140. In this example, the class split is done such that the final classes were approximately equally sized. (In reality, an expert in the field should preferably be consulted to define the split.)

You might recall that we excluded the categorical feature sex from the model the last time you used the diabetes dataset. You will exclude this variable from the model in this example as well. However, the extra variable will be used to analyze the model from a fairness perspective.


Training the Model

Let’s start by training the model. You will use a logistic regression model with only first-order terms. We numerically encode the target variable according to 1=severe progression (positive class) and 0=mild progression (negative class).

Run the code to train the model and evaluate the accuracy on test data.


Confusion Matrices

It is time for the equality analysis. We use the sex variable to compute two confusion matrices over the test dataset, one for each sex (0 or 1). The test set consists of 42 diabetes patients of sex 0 and 47 of sex 1. In the first group, 40.5 % belong to the positive class (i.e. the severe progression class) and the corresponding number in the second group is 48.9 %.

Run the code below to print the confusion matrices.

In the following questions, you will be asked to compute performance metrics for the two sexes, using the confusion matrices obtained.

N.B. the plot_confusion_matrix function from scikit-learn shows a confusion matrix that is transposed (true label on rows, predicted on columns) compared to the one in the course book (true label on columns, predicted on rows).


Question A: Accuracy

Calculate the model accuracy for the two sexes, respectively. Use the code block below for your calculations.


Question B: False Positive Rate

Calculate the false positive rate for each sex.


Question C: True Positive Rate

Calculate the true positive rate for each sex.


Question D: Precision

Calculate the precision for the two groups.


Question I: Interpreting Results

Observing all of the calculated metrics, do you see any performance differences for the two groups? Which of the following statements are true?


Question J: Absolute Fairness

For this example, is it possible to make the model fair in terms of false positive rate, true negative rate and precision at the same time?

Data Bias

The final performance of the machine learning models that we build are largely affected by the data on which they are trained. Bias in the data that we use in the training process can be captured and even exaggerated by the model, counteracting our attempts to achieve model fairness. There are multiple reasons for why data might be biased. One such reason is that the data has not been collected to represent the full intended input space. For example, we might build a model that is intended to be applied to people of all ages, but a certain age group is overrepresented in the dataset. Inevitably, this could result in a model that is better at making predicitons for this particular age group, possibly disfavouring people of other ages. Bias can also follow from human prejudice. Suppose we were to train a model to predict convictions, using data collected from previous cases. If the data does not represent a fair justice system, as a result of human prejudice, the risk is that this pattern will be reproduced and enforced by the model.

The best approach for handling data bias depends on the source of the bias as well as the context. While in some cases, it might be beneficial to remove features from the dataset to avoid issues such as discrimination, this could also have the opposite effect by excluding valuable information. In addition, removing features from the dataset might not help, as features that are still in the dataset could be highly correlated with the excluded ones, and the model might pick up on patterns that we did not anticipate.


Conclusion

Fairness is an important topic in society. As a result, and since we want to be able to employ machine learning models in society, fairness is an important topic in machine learning as well. While it is often not possible to achieve fairness in every regard, we can strive to prioritize and achieve fairness in the regard most essential to the application. We could for example imagine that the model in this example could be used for giving extra medical attention to diabetes patients if predicted to have a severe disease progression. Hence, if there is a systematic difference between detecting severe disease progression between the two sexes, the risk is that one of the groups more regularly experiences negative implications due to inadequate treatment. Therefore, we might put particular value on that the proportion of detected severe progression diabetes patients is equal for both sexes (corresponding to equal true positive rates). We might not, for instance, care as much about wrongly predicting mild progression patients as severe progression, since the negative consequences are not as serious. Of course, some might think the opposite is true or that fairness in terms of precision is enough. Questions like these do often not have true, objective answers and they need to be considered case by case.

Efron, B., Hastie, T., Johnstone, I., & Tibshirani, R. (2004). Least angle regression. Annals of statistics, 32(2), 407-499.

This webpage contains the course materials for the course ETE370 Foundations of Machine Learning.
The content is licensed under Creative Commons Attribution 4.0 International.
Copyright © 2021, Joel Oskarsson, Amanda Olmin & Fredrik Lindsten