Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
Why should you state the denominator with a percentage?
Show the answer
Because 80% of ten items and 80% of ten thousand items carry different confidence.
Count first, then name the rate
Acceptance is the share of retained labels equal to pass. sum(label == "pass" for label in labels) counts True comparisons: True contributes one, False zero. Divide by all retained pass/fail labels, not just the passes. The introductory exercises assume nonempty lists of valid labels; the worked helper also handles empty input explicitly.
The :.0% format turns a fraction into a rounded percent for display. Do not multiply by 100 first. Keep the full numeric rate for comparisons. For tables, create a boolean accepted column, then group by model and take its mean; .items() gives each model and rate to the loop. Default grouping sorts the present model names.
A sample acceptance rate is not agreement with a reference and does not establish general model quality. State the task, retained count and exclusions alongside it. No labelled observations means an undefined rate, represented here by None, not a fabricated zero.
# Count the retained labels before dividing.
def acceptance(labels):
if not labels:
return None
return labels.count("pass") / len(labels)
labels = ["pass", "fail", "pass"]
rate = acceptance(labels)
print("Rows:", len(labels))
print(f"Acceptance: {rate:.0%}")
print("Empty:", acceptance([]))
Three labelled rows support 67% acceptance after display rounding. An empty sample has no rate: None means unavailable, not failure.
Revisit Day 29 for boolean means and group denominators. Next, choose a reproducible sample without pretending it represents everything.
Predict, explain, then test
Answer these three self-reviewed checks before opening the comparisons. They are not scored. Coding checks use unfamiliar inputs under each task’s stated assumptions.
Name the denominator
One pass and two fails support what acceptance fraction?
Compare your answer · self-reviewed
1/3, displayed as 33%. All three labelled observations form the denominator.
Handle absence
Does an empty sample establish 0% acceptance?
Compare your answer · self-reviewed
No. No observations means undefined, represented by None in the worked helper.
Limit a claim
Does a higher sample acceptance rate prove a generally better model?
Compare your answer · self-reviewed
No. Acceptance describes these retained labels; tasks, selection, counts and exclusions matter.
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.