30. Overall Accuracy Across Subgroups

Medium

Overall accuracy is the law of total probability in disguise:

P(correct)=iP(correctgroup i)P(group i)P(\text{correct}) = \sum_i P(\text{correct} \mid \text{group } i)\,P(\text{group } i)

Here you are given raw counts per group rather than proportions, so convert them to weights first. Return the overall accuracy.

solve([700, 300], [0.95, 0.60])  ->  0.845

A model that looks strong on the easy majority can still be dragged down by a small hard subgroup, which is why reporting a single accuracy hides so much.

Sign in to write and run your own code.

Implement solve(...)