Cumulative Gains and Lift

medium
Unit 13 · Recommenders & Metrics0/3 to milestone

Marketing teams rank customers by model score and contact the top slice. Cumulative gain at the top q fraction is the share of all positives captured there; lift is gain divided by q.

Implement gains(y, scores, quantiles) returning a list of (q, gain, lift) for each q in quantiles. Sort by score descending (stable on ties), take the top ceil(q * n) rows, and assume at least one positive.

#metrics#marketing#ranking2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Cumulative Gains and Lift · TechGradify