AP Computer Science Principles · Study guide

Computing Bias

AP® Computer Science Principles · Big Idea 5 · Impact of Computing

Computing Bias

How programs come to treat some groups of people unfairly, where in the building process that bias gets in, and what programmers should do to reduce it.

1What computing bias is

Bias in computing means a program treats some groups of people unfairly in a consistent way: it rates, prices, approves, or recognizes them worse than others. Computing innovations can reflect existing human biases for two reasons:

  • biases in the data the innovation uses or learns from, and
  • biases written into the algorithm, the rules the program follows.

Notice the word existing. The program usually does not invent unfairness; it copies unfairness that was already in past decisions or in its builders' assumptions, and then repeats it automatically. Nobody has to intend harm for this to happen.

Bias in software can be worse than bias in one person. A biased person affects the people they meet. A biased program makes the same unfair call thousands of times a day, everywhere it is used, and people tend to trust it because “the computer decided.”

2Bias in the data

Many programs learn from examples. If the examples leave some people out, or record past unfair decisions, the program learns that pattern. Here is a made-up voice assistant tested on 200 spoken commands from each of three groups:

SpeakersCommands testedMisheardError rate
Accent heard most in the training recordings20042%
A second regional accent200189%
Speakers who learned English later2003015%

Overall it mishears only 8.7% of commands, which sounds fine. But it misheard the third group about 7 times as often as the first, because the recordings it learned from were mostly in one accent. Looking only at the overall number would hide that unfairness.

3Bias written into the algorithm

Bias can also come from the rules people write. A common way is a stand-in: a rule that measures something easy as a substitute for what you care about. Suppose a company's hiring program passes an applicant if they pass a skills test and have lived at the same address for at least 3 years, because the team assumed that “shows reliability.”

GroupApplicantsQualified (passed skills test)Qualified applicants the program passed
Homeowners12060 (50%)48 of 60 (80%)
Renters8040 (50%)16 of 40 (40%)
Figure 1. Half of each group is qualified, but the address rule passes 80% of qualified homeowners and only 40% of qualified renters.

Both groups are equally skilled: half of each passed the test. But renters move more often, so the address rule rejects many of them for a reason that has nothing to do with the job. Nobody wrote “reject renters,” yet the rule does it. Dropping the address rule would pass all 60 qualified homeowners and all 40 qualified renters.

4Every stage of development

Biases can be embedded at all levels of software development, not only in the data:

Figure 2. Bias is not only “bad data.” It can be built in when the goal is set, the data is gathered, the rules are written, the tests are chosen, or the tool is put to use.
StageHow bias gets inMade-up example
Decide the goalsuccess is measured in a way that ignores some groupsa store app is judged only by sales, so features for low-spending customers are never built
Collect the datasome people are missing or underrepresenteda face-unlock feature learns from photos of mostly light-skinned faces
Write the algorithma stand-in rule tracks group membershipyears at one address used as a sign of reliability
Test ittesters all look and sound like the buildersa fitness band is only tested on adults, then sold for kids
Use itno person reviews results and no one can appeala school's plagiarism checker flags students whose first language is not English, and the flags are final

5Reducing bias

Because a program repeats its decisions at large scale, fixing it can undo unfairness at large scale too. Programmers should take action to reduce bias in the algorithms they build, as a way of fighting existing human biases. Match the fix to where the bias came in:

Where it came inAction that reduces it
The datacollect examples from every group the program will be used on; check who is missing
The algorithmquestion every stand-in rule: does it really measure what we care about, or does it track a group?
Testingmeasure results for each group separately, not only the overall average
Uselet a person review important decisions; give people a way to appeal; keep checking results after launch
The key idea

Computing innovations can reflect existing human biases through biased data or through biases written into their algorithms, and bias can enter at every stage of development. Programmers should take action to reduce that bias, for example by checking data, questioning stand-in rules, and testing results for each group.

6Worked examples

Worked Example 1 Name the source

The loan program

A bank's program learns who to approve for loans from 20 years of past approvals. In those years, loan officers often turned down applicants from certain neighborhoods. Explain how the program can be biased.

  1. 1
    The program learns from past decisions, and those decisions were biased.
  2. 2
    So it learns to turn down people from the same neighborhoods, even though no one told it to.
  3. 3
    This is bias in the data, reflecting an existing human bias.
Answer: It repeats the old loan officers' bias, because that bias is in the data it learned from.
Worked Example 2 Use the numbers

The address rule

Using the hiring table above, show that the program is biased even though each group is equally qualified.

  1. 1
    Qualified rates are equal: 50% of homeowners and 50% of renters.
  2. 2
    Passed among the qualified: 48/60 = 80% versus 16/40 = 40%.
  3. 3
    Equally skilled people are treated differently because of the address rule.
Answer: The rule written into the algorithm is biased against renters.
Worked Example 3 Choose the fix

The thermometer app

A health app estimates body temperature from a phone camera. It was tested only on the development team, all in their twenties. Older users report wrong readings. Which action best reduces the bias: (a) add more features; (b) test on people of all ages and adjust; (c) tell older users not to use it?

  1. 1
    The bias came in at the testing stage: one age group only.
  2. 2
    (a) does not touch the cause. (c) excludes a group instead of fixing the program.
  3. 3
    (b) tests the groups the app will be used on and fixes what it finds.
Answer: (b).
Worked Example 4 Evaluate a claim

“Computers are neutral”

A student says: “A computer just follows its code, so it can't be biased.” Evaluate the claim.

  1. 1
    The code and the data both come from people.
  2. 2
    If the data records unfair past choices, or a rule tracks a group, the program repeats that unfairness every time it runs.
Answer: False. Following its code every time is what lets bias in the code or data spread.

7Common mistakes

Common Mistake 1 · Thinking bias needs bad intent

Most bias in software is accidental. It comes from incomplete data or untested assumptions.

Common Mistake 2 · Only blaming the data

Bias can also be written into the rules, or come from the goal, the testing, or how the tool is used.

Common Mistake 3 · Trusting the overall average

An app that is right 91.3% of the time overall can still fail one group far more often. Check each group.

Common Mistake 4 · Confusing bias with the digital divide

If a group cannot reach the program at all, that is the digital divide. If the program reaches them but judges them unfairly, that is bias.

Explain bias like this

“The hiring program is biased against renters because a rule written into the algorithm requires three years at the same address. Renters move more often, so qualified homeowners are passed at twice the rate of qualified renters. The programmers should remove that rule and compare pass rates for each group.”

Say where the bias came from (data, algorithm, or a stage of development), who it harms, and what action would reduce it.