Exercise 1: Fraud Detection With Bayes' Theorem — Possible Solution ==================================================================== GIVEN ------------------------------ P(flagged | fraud) = 0.95 P(flagged | not fraud) = 0.02 P(fraud) = 0.001 (0.1% of all transactions) STEP 1: THE LAW OF TOTAL PROBABILITY — P(flagged) ------------------------------ P(flagged) = P(flagged|fraud) x P(fraud) + P(flagged|not fraud) x P(not fraud) = (0.95 x 0.001) + (0.02 x 0.999) = 0.00095 + 0.01998 = 0.02093 STEP 2: APPLYING BAYES' THEOREM ------------------------------ P(fraud|flagged) = [P(flagged|fraud) x P(fraud)] / P(flagged) = 0.00095 / 0.02093 ~= 0.0454 (about 4.54%) INTERPRETATION ------------------------------ Even though the system correctly flags 95% of real fraud, a flagged transaction is only actually fraudulent about 4.5% of the time. This is this chapter's own base-rate-neglect effect: because genuine fraud is so rare (0.1% of all transactions), the much larger pool of legitimate transactions produces far more false positives (2% of a huge group) than the fraud detector produces true positives (95% of a tiny group). WHY THIS WORKS AS AN ANSWER ------------------------------ The total probability of a flag is built first using this chapter's own law of total probability (accounting for both the fraud and non- fraud paths to a flag), then Bayes' Theorem is applied directly to convert the known P(flagged|fraud) into the actually useful P(fraud|flagged), matching the exact two-step method demonstrated in this chapter's own worked examples.