Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Fairness and bias in AI

After this lesson: I can spot when an AI result may be unfair.

45 min lessonNo commands

Bias in AI

Bias in AI means a program treats some groups of people less fairly than others. A cinema uses an AI tool to pick who gets an interview for a weekend job.

Twenty people apply. Almost everyone it picks lives on the east side of town. Nobody told it to do that, so how did it happen?

By the end of this lesson

Note

I can spot when an AI result may be unfair.

Key words

WordWhat it means
Biasa lean that treats some people less fairly
Fairtreating people alike when they are alike
Grouppeople who share something
Training datathe examples an AI learned from
Shortlistthe people picked to go on to the next step

The cells students fill in are left blank in this preview.

Unfair examples give unfair results

The cinema tool learned from past staff. Most of them lived on the east side, because the old bus route came from there.

So the tool learned "east side" as part of a good worker. That is bias. The training data leaned one way, so the results lean too.

Notice it by comparing groups

You can often spot bias with simple counting. Split the people into groups, then compare how often each group was picked.

If two groups applied in the same way but one is picked far more, ask why.

Worked example: the cinema shortlist

GroupAppliedPickedPicked out of 10As a percentage
East side1066 out of 1060%
West side1022 out of 1020%
Gap4 out of 1040%

The cells students fill in are left blank in this preview.

Count who was picked

Code: python
# Each person is [group, picked]. True means picked.
people = [
    ["east", True], ["east", True], ["east", False], ["east", True],
    ["west", False], ["west", True], ["west", False], ["west", False],
]

applied = {}
picked = {}
for person in people:
    group = person[0]
    if group not in applied:
        applied[group] = 0
        picked[group] = 0
    applied[group] = applied[group] + 1
    if person[1]:
        picked[group] = picked[group] + 1

for group in applied:
    print(group, picked[group], "out of", applied[group])

Turn the counts into a gap

Code: python
# Picked out of applied for each group, from the Run above.
east_picked = 3
east_applied = 4
west_picked = 1
west_applied = 4

east_rate = round(east_picked * 100 / east_applied)
west_rate = round(west_picked * 100 / west_applied)
print("East:", east_rate, "%")
print("West:", west_rate, "%")
print("Gap:", east_rate - west_rate, "%")

What to do when a result looks unfair

Say what you noticed, with the numbers. Tell somebody who can change it: a teacher, a manager, or the report button in an app. Ask for a person to check the decision.

Check your own use too. If you ask AI for pictures or stories about people, look at who is shown and who is missing.

Worked example: who to tell

Where you saw itWho to tell
An app at collegeYour teacher
A tool at a part-time jobYour manager
An app on your phoneThe app report button, or an adult you trust

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think a computer cannot be unfair, because it only follows the data. That is the problem: when the data is one-sided, the results are one-sided too, so the numbers need checking.

Going further: whose pictures?

Think of a picture tool asked for "a scientist" or "a nurse". If it always shows the same kind of person, that is bias in its examples.

Write down two questions you would ask the people who made such a tool.

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.