The University of Melbourne

Bias and Fairness
in Machine Learning

COMP90073Trustworthy Machine LearningHanxun Huang, CISSemester 2, 2026 · Lecture 22
Lecture map

Outline

01Where does unfair ML cause real harm?
02How do we measure fairness?
03Where does bias come from, and how do we reduce it?
Bias and fairness · what is bias?

What is bias in machine learning?

A biased model works worse, or decides worse, for some groups of people.

  • Some groups get worse results.More errors, fewer opportunities, or harmful outputs for some groups.
  • It is often not intentional.Bias appears even when everyone involved has good intentions.
  • It is not one-and-done.A model that is fair today can become unfair later.
  • It is not new.Researchers have raised these concerns for more than 50 years.
Mehrabi, N., Morstatter, F., Saxena, N., Lerman, K., & Galstyan, A. (2021). A survey on bias and fairness in machine learning. ACM Computing Surveys, 54(6), 1–35. https://doi.org/10.1145/3457607
Real-world harm · criminal justice

COMPAS: bias in a criminal risk tool

COMPAS, a risk assessment tool for criminals used by the US government, has shown a harmful bias against African-Americans.

COMPAS risk scores for four defendants
  • A risk score for defendantsIt predicts who will reoffend, on a scale of 1 to 10.
  • Harmful bias against African-AmericansOf people who did not reoffend, labelled high risk: Black 44.9%, white 23.5%.
Real-world harm · quality of service

Gender Shades: worst on darker-skinned women

Face analysis systems misclassify people of colour more often, especially women.

Gender Shades accuracy table and average faces
  • Three commercial APIsMicrosoft, Face++ and IBM, tested on four groups.
  • Big gapsIBM: 65.3% on darker-skinned women, 99.7% on lighter-skinned men.
  • Overall accuracy hides the gapOverall, all three were 88–94% accurate. Only the per-group split shows the gap.
Buolamwini, J., & Gebru, T. (2018). Gender Shades: Intersectional accuracy disparities in commercial gender classification. In Proceedings of the 1st Conference on Fairness, Accountability and Transparency (pp. 77–91). PMLR.
Real-world harm · recommenders

Spread of false information and radicalisation

Search engines and social recommendation systems optimise for user engagement and how long users stay.

News headlines about misinformation on Facebook and Google
  • Optimise for engagementThe ranker shows what gets clicks and keeps you on the site longer.
  • False news gets more clicksOne study: misinformation got six times more clicks on Facebook.
  • Social bubbles formClick a few posts on one view, and your feed fills with that view.
Mehrabi, N., Morstatter, F., Saxena, N., Lerman, K., & Galstyan, A. (2021). A survey on bias and fairness in machine learning. ACM Computing Surveys, 54(6), 1–35. https://doi.org/10.1145/3457607
Real-world harm · pre-trained models

Pre-trained models carry bias to every task

An ImageNet model’s label depends on who is in the photo, not on what they are doing.

ImageNet predictions for basketball and ping-pong players
  • Labelled “basketball”Top row: Black people, most of them not playing basketball.
  • A shortcut from the dataBottom row: similar photos of other people get labels like “ping-pong ball” or “rugby ball”.
  • It spreads downstreamEvery model fine-tuned from it can inherit the shortcut.
Bias and fairness · types of harm

Five kinds of harm

An ML system can be unfair in different ways.

  • Allocation.Unfairly gives out opportunities, resources or information, like loans or jobs.
  • Quality of service.Works worse for some people.
  • Representation.Over- or under-represents some groups, or ignores them.
  • Stereotypes.Repeats and reinforces stereotypes.
  • Denigration.Produces offensive or insulting outputs about a group.
Mehrabi, N., Morstatter, F., Saxena, N., Lerman, K., & Galstyan, A. (2021). A survey on bias and fairness in machine learning. ACM Computing Surveys, 54(6), 1–35. https://doi.org/10.1145/3457607
Fairness · who decides?

What is fair depends on who you ask

There are more than 20 definitions of fairness, and many of them conflict.

  • Individualscare about their own case: would I get a different result if I were different?
  • Policymakers and domain expertsoften look at average outcomes across the population.
  • Lawyers and advocatesfocus on harm and equity, often through individual cases.
  • The mediaoften focuses on single cases, which are sometimes outliers.
Mehrabi, N., Morstatter, F., Saxena, N., Lerman, K., & Galstyan, A. (2021). A survey on bias and fairness in machine learning. ACM Computing Surveys, 54(6), 1–35. https://doi.org/10.1145/3457607
Fairness · three families

Three families of fairness definitions

Each family asks a different question.

  • Group fairness.Do groups get similar statistics? For example, similar approval rates or error rates.
  • Individual fairness.Do similar people get similar predictions, whatever their group?
  • Causal fairness.Would the decision change if only the protected attribute changed?
Measuring fairness · a toy example

A toy loan example

A bank decides who gets a loan. 200 applicants, in two groups of 100.

Group A (100 people)

approveddenied
would repay72TP8FN
would default4FP16TN

80 of 100 would repay

Group B (100 people)

approveddenied
would repay30TP20FN
would default15FP35TN

50 of 100 would repay

\(\hat Y=1\): approved \(\qquad Y=1\): would repay \(\qquad S\in\{\mathrm{A},\mathrm{B}\}\): group

Metric 1 · demographic parity

Demographic parity

Do both groups get approved at the same rate?

Group A
approveddenied
repay728
default416
Group B
approveddenied
repay3020
default1535

Approval rate

Approved people ÷ all people in the group

Group A(72 + 4) / 1000.76
Group B(30 + 15) / 1000.45

Not equal → fails

\(P(\hat Y=1\mid S=\mathrm{A})\;=\;P(\hat Y=1\mid S=\mathrm{B})\)

Example: if 50% of men see a job ad, 50% of women should see it too.

Metrics 2 and 3 · error rates

Equal opportunity and equalized odds

Measure two error rates, then ask: are they equal across groups?

Group A
approveddenied
repay → TPR728
default → FPR416
Group B
approveddenied
repay → TPR3020
default → FPR1535

TPR \(=P(\hat Y=1\mid Y=1,S)\)

Of repayers (blue row), how many got the loan?

Group A72 / 800.90
Group B30 / 500.60

FPR \(=P(\hat Y=1\mid Y=0,S)\)

Of defaulters (red row), how many got the loan?

Group A4 / 200.20
Group B15 / 500.30
Equal opportunity = equal TPR.  0.90 ≠ 0.60 → fails
Equalized odds = equal TPR and equal FPR.  0.20 ≠ 0.30 too → fails

Use these when mistakes hurt people, e.g. wrongly flagging innocent people in COMPAS.

Hardt, M., Price, E., & Srebro, N. (2016). Equality of opportunity in supervised learning. Advances in Neural Information Processing Systems, 29, 3315–3323.
Metric 4 · predictive parity

Predictive parity

Does an approval mean the same thing in both groups?

Group A
approveddenied
repay728
default416
Group B
approveddenied
repay3020
default1535

Positive predictive value (PPV)

Of people we approved, how many repay?

Group A72 / 760.95
Group B30 / 450.67

Not equal → fails

\(P(Y=1\mid\hat Y=1,S=\mathrm{A})\;=\;P(Y=1\mid\hat Y=1,S=\mathrm{B})\)

Example: a loan approval should mean the same chance of repaying in group A and group B.

Metrics · limits

What fairness metrics cannot do

Useful, but they never tell the whole story.

  • They conflict.When groups differ (80% vs 50% repay), no model meets all three metrics. We must choose one.
  • Small groups are noisy.With 8 people, one mistake changes a rate by 12.5%. Report the group size n.
  • The data may be wrong.Missing data, poor proxies and noisy labels change the result.
  • One number hides the cause.It shows a gap, not its cause, e.g. bigger loan requests.
Fairness · error costs

Not all errors cost the same

Which error is worse depends on the application.

  • Loans.A false positive approves someone who defaults: the bank loses money. A false negative denies someone who would repay: they lose an opportunity.
  • Criminal justice.A false positive labels a person high risk when they would not reoffend. This is usually the worse error.
  • Decide with the people affected.Choose the metric and the threshold together, following legal and ethical guidelines.
Fairness · choosing a metric

A decision tree for choosing a metric

Answer a few questions about your application, and the tree suggests a metric.

Aequitas fairness tree
  • Punitive or assistive?Does the decision hurt people (jail) or help them (a benefit)?
  • Who are you most worried about?Everyone in a group, or only the people who need help?
  • The leaf gives the metricFor example: false positive rate parity, or false negative rate parity.
Saleiro, P., Kuester, B., Hinkson, L., London, J., Stevens, A., Anisfeld, A., Rodolfa, K. T., & Ghani, R. (2018). Aequitas: A bias and fairness audit toolkit [Preprint]. arXiv. https://arxiv.org/abs/1811.05577
Sources of bias · the pipeline

Bias can enter at every stage

It is not only the training data.

  • Training data.Historical bias (the world is already biased), representation bias (who is sampled), measurement bias (how features are measured).
  • The model.Algorithmic bias (added by the learning method), evaluation bias (an unrepresentative test set).
  • Deployment.Human bias (people override or misuse predictions), emergent bias (the users or the world change).
Mehrabi, N., Morstatter, F., Saxena, N., Lerman, K., & Galstyan, A. (2021). A survey on bias and fairness in machine learning. ACM Computing Surveys, 54(6), 1–35. https://doi.org/10.1145/3457607
Sources of bias · representation

Most training images come from a few countries

Open Images and ImageNet are dominated by images from the US and Europe.

Share of Open Images and ImageNet images from each country
  • Open ImagesAbout 32% of images come from the US.
  • ImageNetAbout 45% come from the US.
  • Most of the world is missingCountries like India and China, with large populations, have very few images.
Shankar, S., Halpern, Y., Breck, E., Atwood, J., Wilson, J., & Sculley, D. (2017). No classification without representation: Assessing geodiversity issues in open data sets for the developing world [Preprint]. arXiv. https://arxiv.org/abs/1711.08536
Sources of bias · evaluation

Same object, wrong labels

Image APIs work worse on everyday objects from other cultures and countries.

Soap in a UK home and in a Nepal home
  • Two photos of soapLeft: a home in the UK. Right: a home in Nepal.
  • Same APIs, different resultsUK photo: mostly right. Nepal photo: “food, cheese, bread, cake”.
  • Test on real usersTest with photos from many countries and cultures, not only ones like the training data.
DeVries, T., Misra, I., Wang, C., & van der Maaten, L. (2019). Does object recognition work for everyone? [Preprint]. arXiv. https://arxiv.org/abs/1906.02659
Mitigation · where to intervene

Three places to reduce bias

Before, during or after training.

AI Fairness 360 pipeline with intervention points
  • Pre-processingChange the training data. Use it if you can edit the data.
  • In-processingChange how the model is trained. Use it if you can change the training.
  • Post-processingChange the predictions. Use it if the model is a black box.
Bellamy, R. K. E., Dey, K., Hind, M., Hoffman, S. C., Houde, S., Kannan, K., Lohia, P., Martino, J., Mehta, S., Mojsilović, A., Nagar, S., Natesan Ramamurthy, K., Richards, J., Saha, D., Sattigeri, P., Singh, M., Varshney, K. R., & Zhang, Y. (2019). AI Fairness 360: An extensible toolkit for detecting and mitigating algorithmic bias. IBM Journal of Research and Development, 63(4/5), 4:1–4:15. https://doi.org/10.1147/JRD.2019.2942287
Mitigation · methods

Example methods for each stage

A few well-known methods. We look at some of them next.

  • Pre-processing (data).Reweighting (rare group–label rows count more), disparate impact remover, fair data augmentation.
  • In-processing (training).Fairness regularisers, adversarial debiasing, fair representations, DBVAE.
  • Post-processing (predictions).Group-specific thresholds, equalized-odds post-processing, reject option.
In-processing · adversarial debiasing

Adversarial debiasing

Predict the label well, but make it impossible to predict the protected attribute.

Adversarial debiasing architecture
  • Two headsOne head predicts the label \(Y\); the other predicts the protected attribute \(Z\).
  • Reverse the gradientOn the backward pass, the gradient from the \(Z\) head is flipped before it reaches the shared layers.
  • ResultThe features help predict \(Y\), but carry little information about \(Z\).

\(\displaystyle \min\ \sum_{(x,y)}\mathcal L_Y\big(f(g(x)),y\big)\ +\ \sum_{(x,z)}\mathcal L_Z\big(h(J_\lambda(g(x))),z\big)\qquad J_\lambda:\text{ identity forward, }-\lambda\cdot\text{gradient backward}\)

\(x\): input  ·  \(y\): label  ·  \(z\): protected attribute (e.g. gender)  ·  \(g\): shared layers  ·  \(f\): label head  ·  \(h\): adversary head  ·  \(\mathcal L_Y,\mathcal L_Z\): losses

In-processing · adversarial debiasing

Example: word analogies

“He is to she as doctor is to ?” The table lists the closest words, before and after debiasing.

Word analogy results before and after debiasing
  • How to read itNeighbor: a word close to doctor − he + she. Similarity: how close (higher = closer).
  • Before (biased)Top answers: nurse, nanny, fiancée, maid.
  • After debiasingTop answers: nurse, obstetrician, pediatrician, dentist, surgeon.
Zhang, B. H., Lemoine, B., & Mitchell, M. (2018). Mitigating unwanted biases with adversarial learning. In Proceedings of the 2018 AAAI/ACM Conference on AI, Ethics, and Society (pp. 335–340). ACM. https://doi.org/10.1145/3278721.3278779
In-processing · limitations

Limits of adversarial debiasing

Removing the protected attribute can also hurt the main task.

t-SNE features without and with the adversary
  • Accuracy can dropWith the adversary, the classes also get mixed (right).
  • You must name the attributeUnnamed attributes and proxies can remain.
  • Re-check the metricsHiding \(Z\) does not guarantee equal error rates.
Wang, Z., Qinami, K., Karakozis, I. C., Genova, K., Nair, P., Hata, K., & Russakovsky, O. (2020). Towards fairness in visual recognition: Effective strategies for bias mitigation. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 8919–8928). IEEE.
Pre-processing · fair data augmentation

Generate the missing examples with a GAN

If “hat” always comes with “glasses” in the data, generate examples that break the link.

Real data and GAN paired augmentation
  • A spurious linkIn the real data, people with hats also wear glasses.
  • Paired augmentationA GAN makes pairs: same hat, glasses added or removed.
  • Train on bothNow hat and glasses are no longer linked.
Ramaswamy, V. V., Kim, S. S. Y., & Russakovsky, O. (2021). Fair attribute classification through latent space de-biasing. In 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 9297–9306). IEEE. https://doi.org/10.1109/CVPR46437.2021.00918
In-processing · DBVAE

DBVAE: find and up-sample rare faces

Learn which faces are rare in the training data, and show them more often.

Training batches without and with DBVAE
  • A normal batch (left)Mostly similar faces: light skin, frontal, no occlusion.
  • A DBVAE batch (right)More diverse: skin colour, lighting, hats and occlusions.
  • No labels neededThe model finds the rare features by itself.
Amini, A., Soleimany, A. P., Schwarting, W., Bhatia, S. N., & Rus, D. (2019). Uncovering and mitigating algorithmic bias through learned latent structure. In Proceedings of the 2019 AAAI/ACM Conference on AI, Ethics, and Society (pp. 289–295). ACM. https://doi.org/10.1145/3306618.3314243
In-processing · DBVAE

How DBVAE resamples

Rare latent codes get a higher chance of being picked for training.

DBVAE architecture
  • Encode each faceA VAE encoder maps each face to a latent code \(z\).
  • Estimate how common it isA histogram \(\hat Q\) of the codes shows which faces are rare.
  • Sample rare faces moreWeight \(W\) is large when \(\hat Q\) is small.

\(\displaystyle W(z(x)\mid X)\ \propto\ \prod_i\frac{1}{\hat Q_i(z_i\mid X)+\alpha}\)

\(x\): a face  ·  \(X\): all training faces  ·  \(z(x)\): its latent code  ·  \(z_i\): the \(i\)-th latent variable  ·  \(\hat Q_i\): histogram of \(z_i\)  ·  \(\alpha\): debiasing strength  ·  \(W\): sampling weight

Amini, A., Soleimany, A. P., Schwarting, W., Bhatia, S. N., & Rus, D. (2019). Uncovering and mitigating algorithmic bias through learned latent structure. In Proceedings of the 2019 AAAI/ACM Conference on AI, Ethics, and Society (pp. 289–295). ACM. https://doi.org/10.1145/3306618.3314243
In-processing · DBVAE

Which faces does DBVAE up-sample?

Result on CelebA: most faces have a tiny resampling probability; a few rare ones get much more.

DBVAE resampling probabilities on CelebA
  • Most faces: low probabilityThe histogram: most faces have a very small chance of being picked.
  • Lowest probability (B)Similar faces: lighter skin, frontal, no hats.
  • Highest probability (C)Darker skin, hats, unusual poses and lighting.
Amini, A., Soleimany, A. P., Schwarting, W., Bhatia, S. N., & Rus, D. (2019). Uncovering and mitigating algorithmic bias through learned latent structure. In Proceedings of the 2019 AAAI/ACM Conference on AI, Ethics, and Society (pp. 289–295). ACM. https://doi.org/10.1145/3306618.3314243
Summary

Bias and fairness: summary

  • Unfair ML causes real harm.COMPAS, Gender Shades, recommenders and pre-trained models.
  • Fairness metrics can conflict.Choose one with the people affected.
  • Bias enters at every stage.Training data, the model, and deployment.
  • Reduce it early, and keep checking.Fix it in the data if you can, and audit again after deployment.
  • Toolkits help you measure.AI Fairness 360, Fairlearn, Aequitas, What-If Tool. They do not decide what is fair.

Next lectureGuest lecture: Dr Jun Wang (Amazon)