22. Precision and Recall

Medium

Precision and recall are the same overlap read with different denominators, which is exactly why P(AB)P(BA)P(A \mid B) \neq P(B \mid A):

Precision=TPTP+FPRecall=TPTP+FN\text{Precision} = \frac{TP}{TP + FP} \qquad \text{Recall} = \frac{TP}{TP + FN}

Return a dict with keys "precision" and "recall". If a denominator is zero, use 0.0 for that metric.

solve(10, 10, 30)  ->  {"precision": 0.5, "recall": 0.25}

Sign in to write and run your own code.

Implement solve(...)