Unit 5: Data analysis · Bias in machine learning

Article

Algorithmic bias

8 min read

A computer has no opinions. It does not like or dislike anyone. So how can a program treat some people worse than others? The answer is that programs are built by people, and they learn from data that people collected. Unfairness can travel along that road without anyone planning it.

What algorithmic bias is

Bias means unfair results that repeat: one group of people is treated worse (or better) than others, again and again. When a computer program does this, it is algorithmic bias.

Bias does not need a bad intention. Most of the time nobody wanted it. People have unfair beliefs and habits, and these can pass into computing in two ways:

  • Biased data. The data the program learns from is incomplete or unfair.
  • Biased design choices. The people who built it made choices (what to measure, what counts as a good result) that favour some groups.

This is the idea the AP exam wants: computing innovations can reflect existing human biases, because of biased data or biased choices in the program. The people who build them should work to reduce the bias.

Check your understanding

Which sentence best describes algorithmic bias?

Where bias comes from

Bias can enter at every step of building a system, not only at one.

Bias can enter at every step

  1. Collect data

    Some groups are missing, or the data records unfair history.

    choose
  2. Choose what to measure

    A stand-in measure favours some people.

    train
  3. Train the model

    The model copies the patterns it is given.

    check
  4. Test it

    Only some kinds of people are tested.

    release
  5. Use it

    It is used on people it was not built for.

A fair result needs care at every step. One careful step does not cancel an unfair one.

Here are the most common sources, with invented examples.

SourceWhat goes wrongExample
Missing or rare groupsToo few examples of some people, so the model guesses about themA voice tool is trained mostly on adult voices. It works worse for children.
Unfair historyThe data records past unfair decisions, and the model repeats themA tool learns from old hiring decisions in which one group was often turned down. It turns that group down too.
What is measuredThe measure is a stand-in that favours some peopleA scholarship tool counts hours of online practice at home as "effort". Students with no home Internet score lower, however hard they work.
Uneven collectionSome people were much more likely to be countedA survey is answered only through a smartphone app. People without smartphones are missing.
Who builds and testsThe team is alike, so no one thinks of other usersAn app is tested only by its developers, who are all about the same age. It is hard to use for older people.

The scholarship example is the digital divide again. A gap in access becomes a gap in data, and then a gap in results.

Check your understanding

A scholarship tool was trained on past students from city schools only. It now gives lower scores to students from village schools. What is the most likely cause?

What reduces bias

The summary of this lesson, on one page:

Algorithmic bias at a glance

Algorithmic bias
  • Where it comes from

    • too few examples of some groups
    • data that records past unfairness
    • a measure that favours some people
    • a team that tests only on people like itself
  • What it causes

    • more mistakes for some groups
    • fewer chances such as loans or jobs
    • unfairness repeated at a huge scale
  • What reduces it

    • representative data
    • testing each group separately
    • human review
    • transparency
    • a varied team
Each cause has a matching fix. Matching them is the exam skill.
  • Representative data. The data includes every group the system will be used on, in good numbers.
  • Test each group separately. One overall score can hide a group that does badly. Run the code to see how.
  • Human review. For important decisions, a person checks the result, and people can appeal.
  • Transparency. Be open about what data and measures the system uses, and how well it works for each group.
  • A varied team. People with different backgrounds notice problems that others miss.
  • Keep checking. Test again after release, because the people using it change.
Runs in your browser

"85% right" sounds good. But for Group B it is only 40%. Group B is small, so it hardly changes the overall number. Change b_right to 9 and run it again.

Worked example

For each scenario, name the source and choose an action.

ScenarioSourceBest action
A speech tool, trained on recordings from its own staff, mishears people with other accentsMissing groups in the dataAdd recordings of many accents and test on each
A study-help app ranks students by hours online at homeWhat is measuredUse a measure that does not depend on home Internet
A health app is tested only on the developers' familiesWho tests itTest on people of different ages and backgrounds

Common mistakes

  • "A computer is neutral, so it cannot be biased." It copies the data and the choices it is given.
  • "Bias means someone meant to be unfair." It usually happens by accident.
  • "Bias comes only from the data." The choice of what to measure, the testing and the team matter too.
  • "Delete the column about the group and the problem is gone." Other columns, such as a home area, can stand in for it.
  • "A high overall score means it is fair." Look at each group.

On the exam

You may get a scenario in which a system works worse for one group. Ask: what was in the data, what was measured, who tested it? The best cause is usually under-represented data or an unfair choice. The best fix is usually more representative data, testing across groups, or human review. Be careful of answers that blame the computer for "disliking" people, or that only make it faster.

Key words

Bias: unfair results that favour some groups over others.

Algorithmic bias: bias in a computer program's results, from biased data or biased design choices.

Representative data: data that includes every group the system will be used on.

Transparency: being open about how a system works, what data it uses and how well it performs.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse, this site. All lessons and questions here are written by JrCodex.