Search Knowledge

© 2026 LIBREUNI PROJECT

Machine Learning / MLOps & System Deployment

Ethics in Machine Learning

Ethics in Machine Learning

As machine learning systems are increasingly deployed to automate high-stakes decisions, it is critical to address algorithmic bias and ensure fairness.

Sources of Algorithmic Bias

Algorithmic bias arises at multiple pipeline stages:

  • Historical Bias: training data reflects existing systemic human prejudices.
  • Representation Bias: sample underrepresents demographics, raising error rates for minorities.
  • Measurement Bias: collected features are noisy, poor proxies of the target task.

Mathematical Definitions of Fairness

Fairness is defined mathematically, but different metrics are often mutually exclusive. Let AA be a sensitive attribute (e.g., race, gender), XX be the remaining features, YY be the true label, and Y^=f(X)\hat{Y} = f(X) be the model prediction.

1. Demographic Parity (Statistical Parity)

The likelihood of receiving a positive prediction is independent of the sensitive attribute:

P(Y^=1A=0)=P(Y^=1A=1)P(\hat{Y} = 1 | A = 0) = P(\hat{Y} = 1 | A = 1)

2. Equal Opportunity

The true positive rate (recall) is equal across all demographic groups:

P(Y^=1A=0,Y=1)=P(Y^=1A=1,Y=1)P(\hat{Y} = 1 | A = 0, Y = 1) = P(\hat{Y} = 1 | A = 1, Y = 1)

3. Predictive Parity

The precision (positive predictive value) is equal across all demographic groups:

P(Y=1A=0,Y^=1)=P(Y=1A=1,Y^=1)P(Y = 1 | A = 0, \hat{Y} = 1) = P(Y = 1 | A = 1, \hat{Y} = 1)

These definitions are mathematically incompatible if the base rates differ between demographic groups, meaning a model cannot satisfy all of them simultaneously unless it makes perfect predictions.

Example: Evaluating Fairness

The following example calculates demographic parity difference between two groups:

python

Interactive Lab

Evaluate Demographic Parity by calculating the difference in selection rates between two demographic groups. Adjust the predictions to see if you can reduce the difference to zero.

Step 1
Inspect the idea
Step 2
Edit the program
Step 3
Run and compare

Exercise

Test your understanding of mathematical fairness constraints:

Why is it mathematically impossible to satisfy demographic parity, equal opportunity, and predictive parity simultaneously in a non-trivial predictor?

References & Further Reading

Previous Module Reinforcement Learning
Finish Course