Skip to content
Start free

What number did the AI divide by to get your percentage?

Find the number on the bottom of a satisfaction percentage and recompute the two that come out of the same survey.

Free course. Your Maestro, an AI, .

The second question is what did it divide by? Every percentage is a division: something you count on top, divided by something you count on the bottom. The one on the bottom is called the denominator, and it almost never appears in the sentence the AI gives you.

Imagine you hand your assistant the hardware store's March satisfaction survey and ask "what percentage of our customers are satisfied?" Imagine it answers:

88.9% of customers are satisfied (rating of 4 or 5).

The survey was sent to the 112 paid tickets of the month, one row per ticket. Forty-five answered. Of those 45, 40 rated 4 or 5. The 88.9% is 40 out of 45: the percentage of those who answered. Out of everyone it was sent to, 40 out of 112 is 35.7%.

The top bar and the bottom bar have the same number of satisfied customers. The only thing that changes is the base:

Synthetic course data (encuesta-marzo, CC0).

Both numbers are correct. They answer different questions:

  • 88.9%: of the people who answered, how many were satisfied?
  • 35.7%: of all the people we asked, how many told us they were satisfied?

The problem appears when the sentence says "of customers" and doesn't say which ones. Anyone who reads "89% of customers are satisfied" will understand that almost all customers are, and the survey knows nothing about the 67 who didn't answer. So which of the two do I put in my report?

Three questions for any percentage

  1. Whose is it? All customers, those who answered, registered customers, paid tickets? That is the base.
  2. What was counted on top? Here "satisfied" is 4 or 5. If it were only 5, it would be 26 out of 45, 57.8%. Someone chose the definition; ask the AI to state it.
  3. Who dropped out of the bottom? Empty cells, people who didn't answer, rows a filter removed. What leaves the denominator changes the result without showing in the sentence.

The habit you take from this page is short: every percentage goes with its "out of how many." Not "89% satisfaction," but "40 of the 45 who answered (89%)."

How each one is calculated

These lines use the calificacion column, which is empty when the person didn't answer:

Python · lines 4–5
contestaron = data["calificacion"].notna().sum()   # how many cells have a rating
satisfechos = (data["calificacion"] >= 4).sum()    # how many ratings are 4 or 5
encuestados = len(data)                            # how many were sent the survey
satisfechos / contestaron                          # proportion among those who answered
satisfechos / encuestados                          # proportion among everyone
The last two lines have the same number on top. Only the one on the bottom changes.

Two new pieces:

  • notna() asks "does this cell have anything in it?" for each row, and .sum() counts how many times the answer was yes.
  • (data["calificacion"] >= 4) asks "is it 4 or more?" for each row. Again, .sum() counts the yeses. An empty cell answers no.

A proportion like 0.889 is the same as 88.9%: you multiply by 100.

Try it

The exercise uses the March survey. It already counts who answered and who was satisfied. Complete the two divisions and compare them with the AI's 88.9%. Then change the definition of satisfied to "only 5" and see what happens. I don't know what the right denominator is for my case.

Calculate the percentage of satisfied customers with the two bases: among those who answered and among everyone surveyed. You are done when the output shows 88.9 and 35.7. For the second part, change = 4 to == 5 and run it again: what does each percentage become?

Calculate the percentage of satisfied customers with the two bases: among those who answered and among everyone surveyed. You are done when the output shows 88.9 and 35.7. For the second part, change >= 4 to == 5 and run it again: what does each percentage become?

Run your code to see what it prints and the value of its last expression. Every run starts fresh.

Ready to run your code.

Run your code to see its output here.

Data: encuesta-marzo, 112 rows

Enter saves a cell and Escape leaves it as it was. Leave a cell empty for a missing value.

The exercise's data, "encuesta-marzo". Your edits run with your code.
RowRemove
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Page 1 of 6

Run it yourself

With == 5 you should get 57.8% among those who answered and 23.2% among everyone. Four different numbers for "how satisfied are our customers?", all correctly calculated. That is why the number alone is not enough: what you need is the number with its base and its definition.

Check yourself: With the same survey, the AI tells you "89% satisfaction" and a report from your coworker says "36% satisfaction." What is most likely?