75% of whom?
An AI says 75% are satisfied. Name the denominator it used, and compute the share over the group the question names.
3 parts · 2, 4 and 2 min
Free course. Your Maestro, an AI, .
In the last module, you checked an AI's average bill per visit across 7 billing lines from 4 clinic visits totaling $520. What divisor did you need on the bottom of that fraction to get the average per visit? Answer before you read on.
Every Glossary word has a divisor hiding inside it too. When an AI reports "75% of staff are satisfied", that single number comes from dividing a count on top (the numerator) by a group on the bottom (the denominator). Before you put that percentage into a report, you need to name the denominator the code used in plain words and check whether it matches the group the sentence names.
HR sent a satisfaction survey to all 12 people on staff, labeled "p01" through "p12". In the survey table, each invited staff member has one row:
- 1.0 means the person responded and said they were satisfied (6 people).
- 0.0 means the person responded and said they were not satisfied (2 people).
Nonemeans the person did not turn in the survey (4 people).
HR asked: "What share of staff are satisfied?" The AI answered "75% of staff are satisfied" by running survey["satisfied"].mean().
Why did the AI use a Glossary word to get a percentage? When a column holds only 1.0 and 0.0 values, adding the column with survey["satisfied"].sum() adds 1.0 for each satisfied person and 0.0 for everyone else, giving 6.0. Dividing that sum by the size of the group gives the share of satisfied people.
The catch is which group survey["satisfied"].mean() puts in the denominator when a column has blank cells:
len(survey)counts every row in the table: 12 staff members invited.survey["satisfied"].count()counts only the non-blank cells: 8 staff members who responded.- In Glossary word,
.mean()skipsNonecells instead of treating them as 0.0. It takessurvey["satisfied"].sum()(6.0) and divides bysurvey["satisfied"].count()(8), computing6 / 8 = 0.75, or 75%.
If you expected .mean() to treat the 4 blanks as zeros and divide by 12, ask your Maestro how pandas handles missing values in a column average.
Which denominator belongs in the report?
Both 75% (6 / 8) and 50% (6 / 12) are valid fractions, and each one answers a different question:
- Denominator of 8 (respondents): 75% of the staff who answered the survey said they were satisfied.
- Denominator of 12 (all invited staff): 50% of all staff are confirmed satisfied, and another 4 people (33%) did not respond.
The flaw in the AI's answer is the mismatch between its code and its sentence. The code divided by the 8 respondents, while the words "75% of staff" tell the reader the denominator was all 12 staff members.
Try it
Find what the AI divided by, compute the share over everyone invited, and write the sentence you would put in the report.
A good place to stop. Up next: the exercise · 4 min
A good place to stop. Up next: part 3 of 3 · 2 min
When you print every piece of the calculation alongside the AI's result, your output looks like this:
AI: 0.75Invited: 12Responded: 8Satisfied: 6Over invited: 0.5Compare the two denominators side by side:
survey["satisfied"].mean()computed6 / 8 = 0.75becausesurvey["satisfied"].count()is 8. Its denominator is the 8 staff members who responded.survey["satisfied"].sum() / len(survey)computed6 / 12 = 0.5becauselen(survey)is 12. Its denominator is all 12 staff members invited.
Whenever a survey has missing responses, a bare percentage leaves the reader guessing who was left out of the denominator. Rewrite the AI's sentence by naming the group in the denominator and giving the counts:
"Of the 12 staff invited, 8 responded, and 6 of those 8 (75% of respondents, or 50% of all staff) said they were satisfied."
Paste the sentence you would send to HR to your Maestro if you want feedback on whether your wording makes the denominator clear.