Measure a Detection Rate
Beginner · Write the code · from Computing Bias and Crowdsourcing: Unfair Data, Shared Effort
From the lesson: How can programmers reduce bias?
Programmers should act to reduce bias in the algorithms they build. Otherwise computing repeats existing human biases, only faster and for millions of people at once. Steps that help: - Build diverse teams, and ask a wide range of users for feedback while designing.
Read this part of the lessonWrite detection_rate(readings, threshold) that returns the percent of readings that are at or above threshold, rounded to 1 decimal place. If readings is empty, return 0.0 instead of crashing.
detection_rate([50, 30, 45, 20], 40) -> 50.0def detection_rate(readings, threshold):
# Return the percent of readings >= threshold, rounded to 1 decimal
pass
What Check runs
Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(detection_rate([50, 30, 45, 20], 40)) | 50.0 |
| print(detection_rate([81, 77, 92], 42.8)) | 100.0 |
| print(detection_rate([38, 45, 41], 42.8)) | 33.3 |
More Computing Bias exercises
- Accuracy for Each GroupIntermediate
- The Crowd's EstimateIntermediate