24 Classification and Rare Events
Opens by correcting a conflation from Chapter 1: a rare positive class isn’t automatically a heavy-tail problem, but it creates a similar practical trap — a classifier that always predicts “no event” can hit 99.99% accuracy and be useless.
def precision(tp, fp): return tp / (tp + fp) if (tp+fp) else 0
def recall(tp, fn): return tp / (tp + fn) if (tp+fn) else 0