Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
What two numbers define a rate?
Show the answer
A count of matching cases and the total eligible cases.
Every average needs a denominator
groupby("model") gathers rows with the same model. size counts all group rows; count on score counts only present scores; mean on score averages only those present scores. By default, missing grouping keys are excluded. A group with no scores has a missing mean, not score zero.
For typed pass/fail labels, comparing with pass creates booleans. Their mean is the fraction of passes: True contributes one, False zero. Round after aggregation, not before. The introductory rate assumes valid labels; the independent audit makes exclusions explicit.
These fixture rates describe the retained sample, not general model quality or a fair ranking. Different sample sizes, exclusions or tasks can change them. print dictionaries for inspection; key order and 5 versus 5.0 display do not change their numeric meaning.
# Every average needs a denominator.
import pandas as pd
df = pd.DataFrame([
{"model": "Museum", "score": 5},
{"model": "Museum", "score": None},
{"model": "Canal", "score": 2},
])
print(df.groupby("model").size().to_dict())
print(df.groupby("model")["score"].count().to_dict())
print(df.groupby("model")["score"].mean().to_dict())
Museum has two rows but only one scored row, so its mean is 5.0, not 2.5. Canal has one row, one score and mean 2.0.
Report how many rows and scores support a mean. Next, decide which observations should be retained before summarizing.
Predict, explain, then test
These three brief checks are self-reviewed, not scored. Answer before opening the comparison. Coding checks use unfamiliar tables under the stated task assumptions.
Choose a count
A group has two rows and one missing score. What do size and score.count report?
Compare your answer · self-reviewed
size is two rows; score.count is one observed score.
Name a denominator
One pass and two fails have what acceptance rate, rounded to two decimals?
Compare your answer · self-reviewed
0.33. The denominator is all three retained labelled rows.
Limit interpretation
Does the larger mean from this fixture establish the better model overall?
Compare your answer · self-reviewed
No. It describes this retained sample; tasks, sample sizes and exclusions may differ.
Choose an exercise to load its prompt.
Loading exercises…
Noted on your route map, with the step you were on. Nothing is lost by parking it — the next review day will bring this idea back, and the flag tells the course where to slow down.
The tutor mounts here when JavaScript is available. The lesson above stays readable without it.