A spam filter is graded on two numbers. Precision: of the emails it flagged, the share that really are spam. Recall: of all the spam, the share it flagged. Write filter_score(precision, recall): one number for how good the filter is, from 0 (useless) to 1 (perfect).
A filter sorts 40 emails, 15 of them spam, moving the ones it suspects into the spam folder. Precision grades the folder, recall grades how much of the spam it caught. Your function turns the two into one grade.
filter_score(precision, recall)| precision | share of flagged emails that really are spam | e.g. 1 |
| recall | share of all spam that got flagged | e.g. 1 |
| returns | one score from 0 (useless) to 1 (perfect) | |