Turn a ranked response model into an auditable contact-capacity curve with attainable thresholds, cohort counts and a random-selection baseline.
Cumulative gains and lift: rank contacts without hiding score ties
Define the decision population
A cumulative gains chart asks how many confirmed responders appear among the highest-ranked share of eligible contacts. The horizontal axis is contacts selected divided by all eligible contacts. The vertical axis is responders captured divided by all confirmed responders. Lift at that point is gain divided by selected share. These are different denominators; mixing them produces an impressive-looking but meaningless line. Freeze the eligibility rule, scoring date, response window and label-maturity rule before ranking. An unobserved response is not automatically a negative response. Grain and denominator checks belong beside the chart, especially when one customer has several campaign records.
Use a reachable threshold
Sort by descending score and advance one whole score group at a time. Equal scores cannot be separated using the model score alone. A budget of 47 contacts might land inside a tie containing 11 people. Either contact the whole tied group, stop before it, or apply a declared secondary rule that the team can reproduce; do not show a fractional customer as an attainable decision. Plot points after complete groups, print the actual selected count, and draw the random-selection gain baseline as selected share. The random baseline has lift one at every positive selected share. ROC thresholds face the same tie issue, but their horizontal axis divides false alerts by actual non-events rather than contacts by all eligible records.
Read lift with capacity, not as a trophy
If the top quarter contains half of all responders, cumulative lift at that contact depth is two. It does not mean the model doubles every person's response probability. Cumulative lift generally approaches one when all eligible contacts are selected, so a large value at a tiny first group should not dominate the decision. Show selected count, captured responders, gain and lift at each usable capacity. If outreach cost varies by channel or customer, a count-based gain curve is insufficient; calculate expected net value under the actual contact rule. Precision–recall curves show positive yield among selected contacts and are a useful companion, while calibration asks whether the scores themselves can be read as probabilities.
Protect evaluation against selection bias
A campaign label is often observed only for people previously contacted. Ranking that historical contacted subset can make a new model appear stronger than it is for the full eligible population. Record who had a chance to respond, the old contact policy, and whether the evaluation uses randomized outreach or an appropriate correction. Compare candidate models on the same held-out cohort and response window. If outcome prevalence changes, gains and lift at a fixed share may shift because the target population changed. Slice by campaign, region or customer tenure only when each slice has enough confirmed responders to support the curve. Small-sample displays should expose the event counts behind sharp early jumps.
Worked contract
from math import isfinite
def gains_ledger(contacts: list[tuple[str, float, bool]]):
contact_ids = [contact_id for contact_id, _, _ in contacts]
if not contacts or len(contact_ids) != len(set(contact_ids)) or any(
not contact_id for contact_id in contact_ids):
raise ValueError("contacts need unique, nonempty IDs")
if any(not isfinite(score) or type(responded) is not bool
for _, score, responded in contacts):
raise ValueError("scores must be finite and responses must be known")
total_responses = sum(responded for _, _, responded in contacts)
if total_responses == 0:
raise ValueError("gain is undefined without responders")
ranked = sorted(contacts, key=lambda record: record[1], reverse=True)
selected = captured = cursor = 0
points = [(None, 0, 0.0, 0.0, None)]
while cursor < len(ranked):
threshold = ranked[cursor][1]
while cursor < len(ranked) and ranked[cursor][1] == threshold:
captured += ranked[cursor][2]
selected += 1
cursor += 1
share = selected / len(ranked)
gain = captured / total_responses
points.append((threshold, selected, share, gain, gain / share))
return points
campaign_contacts = [("contact-47", 0.94, True),
("contact-59", 0.87, False),
("contact-83", 0.87, True),
("contact-97", 0.61, False),
("contact-101", 0.55, True),
("contact-131", 0.31, False),
("contact-149", 0.21, False),
("contact-173", 0.08, False)]
trace = gains_ledger(campaign_contacts)
assert trace[2][:4] == (0.87, 3, 3 / 8, 2 / 3)
assert abs(trace[2][4] - 16 / 9) < 1e-12
assert trace[-1][1:] == (8, 1.0, 1.0, 1.0)Performance and operating cost
Sorting N contacts takes O(N log N) time; the grouped sweep takes O(N) time. The ranked records, ID set and returned points use O(N) space. The eight-contact check proves that a tied score contributes a single attainable point and gives lift 16/9 after selecting three contacts. That tiny ledger illustrates arithmetic only. It does not estimate campaign return or correct selective labels from past outreach.
Common Mistakes
- Using responders among selected contacts as cumulative gain; that ratio is precision.
- Splitting tied scores to make an exact budget look reachable without a secondary rule.
- Comparing lift measured on different eligible populations or outcome windows.
- Calling never-contacted people nonresponders when their outcome cannot be observed.
Validation drill
Take 470 eligible contacts with mature response labels and a fixed campaign window. Mark every tied threshold, then publish selected count, captured responders, gain, lift and outreach cost at capacities 47, 94 and 141; explain any capacity that falls inside a tie.
