skip to content

As drift scores for a heavy-tailed claimed-amount input, how do PSI, Jensen–Shannon and Wasserstein-1 differ, and which would you choose?

level: middleimportance: should knowfreq 44%

answer

  1. bins versus the feature's own axis
  2. JS: bounded, the average is never empty
  3. three scores, three scales
  4. W1 = area between the two CDFs
  5. the top bin is open-ended

basics

~20 s

PSI and Jensen–Shannon score how bin shares changed (PSI unbounded, JS at most ln 2 in nats); Wasserstein-1 is the area between the two CDFs, in currency, so it sees how far amounts moved. For a heavy tail, add a scaled Wasserstein.

solid answer

~50 s

PSI and Jensen–Shannon both work on shares in frozen reference-quantile bins. PSI is unbounded and infinite when a bin empties; JS compares each window with their average, so it stays finite with a one-sided empty bin and is bounded by ln 2 in nats (1 in bits). On unshifted data JS runs about one-eighth of PSI, so their numbers are not interchangeable. Wasserstein-1 is the area between the two CDFs: no bins, in the feature's own units, and it says how far mass moved. For a claimed amount that matters: if every top-decile claim arrives 40,000 higher, no bin share changes, so PSI and JS stay at zero, while W1 = 0.1 × 40,000 = 4,000. I'd pair a binned score with Wasserstein divided by a reference spread, accepting that W1 also reacts to a few extreme claims.

code

pseudocode · 12 lines
pseudocode
function wasserstein_1d(reference, live):
    # area between the two empirical CDFs, walked over the merged sorted values
    xs = sort(reference)
    ys = sort(live)
    points = sort(xs + ys)
    area = 0
    for k in 0 .. length(points) - 2:
        x = points[k]
        f = count_at_or_below(xs, x) / length(xs)
        g = count_at_or_below(ys, x) / length(ys)
        area += abs(f - g) * (points[k + 1] - x)
    return area   # in the feature's own units

go deeper

for a junior

Know that PSI and Jensen–Shannon compare bin shares while Wasserstein measures how far values moved, in the feature's units.

for a middle

Explain JS's bound with its log base, why it survives a one-sided empty bin, why W1 is the area between CDFs, and why the three scales are not interchangeable.

for a senior

Use the heavy tail to argue the choice: moves inside the open top bin are invisible to binned scores, while W1 sees them but also reacts to single extreme claims.

for a principal

Decide per feature type what a platform reports by default, and insist that Wasserstein is scaled before features are compared or ranked together.

## Three things a drift score can tell you For one numeric model input, such as the claimed amount on a claims-triage model that routes claims to fast-track, adjuster review or special investigation, a drift score compares a **reference window** with a **live window**. Scores differ in what they can see: - whether mass moved between fixed **bins** (PSI, Jensen–Shannon); - whether the score is **bounded**, so one feature cannot blow up the scale; - **how far**, in the feature's own units, the values moved (Wasserstein-1). ## PSI and Jensen–Shannon: shares in frozen bins Both start from the same bins — edges cut at reference quantiles and frozen — and the same shares, reference `e_i` and live `a_i`. - **PSI** is `Σ (a_i − e_i) · ln(a_i / e_i)`: symmetric, non-negative, unbounded, and undefined when a bin share is zero. - **Jensen–Shannon (JS)** compares each window with their average `M = (a + e) / 2`: `JS = ½ KL(a ‖ M) + ½ KL(e ‖ M)`. Because `M_i` is positive whenever either window has mass in bin i, JS stays **finite when a bin is empty on one side**. It is **bounded** — at most ln 2 ≈ 0.693 with natural logarithms, or 1 with base-2 logarithms — and its square root, the **Jensen–Shannon distance**, is a true metric. The two live on different scales. On the same unshifted samples, JS runs about **one-eighth** of PSI and KL about half (natural logs). In a four-bin example with live shares 0.15, 0.20, 0.25, 0.40 against 0.25 each, PSI is about 0.133 and JS about 0.016 nats. A JS of 0.02 and a PSI of 0.02 describe very different situations. ## Wasserstein-1: how far the mass moved **Wasserstein-1**, also called the earth mover's distance, is in one dimension the **area between the two cumulative distribution functions**: `W1 = ∫ |F_ref(x) − F_live(x)| dx` which equals the area between the two quantile functions. Its properties are the ones binned scores lack: - **No bins.** It is computed from the sorted samples directly, so there are no edges to choose and no empty-bin problem. - **The feature's own units.** For a claimed amount the score is in currency; shift every claim by 1,000 and W1 is exactly 1,000. - **It sees distance.** Mass that moves far contributes more than mass that moves a little. Worked on tiny samples: reference amounts 1,000, 2,000, 3,000, 4,000 and live amounts 1,000, 2,000, 3,000, 40,000. Paired in sorted order the gaps are 0, 0, 0 and 36,000, so W1 = 36,000 / 4 = 9,000. ## Where the heavy tail decides it Suppose every claim in the top decile starts arriving 40,000 higher while the other 90% are unchanged. Those claims were already in the open-ended top bin and stay there, so **every bin share is unchanged: PSI = 0 and JS = 0**. Wasserstein sees it: the quantile functions differ by 40,000 over the top 10% of quantiles, so W1 = 0.1 × 40,000 = 4,000 currency units. For a model that sends large claims to special investigation, that tail is exactly what matters. The same property cuts the other way: W1 reacts to a few extreme values. In a 500-claim window, one claim landing 2,000,000 above where its quantile partner sat can add up to 2,000,000 / 500 = 4,000 on its own, where a binned score barely registers it. ## Choosing for the claimed amount | Score | What it sees | Units and bound | Breaks when | |---|---|---|---| | PSI | mass moving between frozen bins | unitless, unbounded | a bin empties; tiny windows; moves inside a bin | | Jensen–Shannon | the same, against the average | ≤ ln 2 nats (1 bit) | moves inside a bin; still inflated by tiny windows | | Wasserstein-1 | how far values moved | feature units, unbounded | comparing features unscaled; single extreme values | A defensible design for a heavy-tailed amount pairs a binned score — JS where windows are small or bins may empty — with a **scaled** Wasserstein: divide W1 by a reference spread, the standard deviation or, for a heavy tail, the interquartile range, so it becomes unitless and comparable across numeric features. What value of either score should prompt action is a separate, threshold question. ## Pitfalls - Quoting "JS is at most 1" without saying the logarithm base. - Ranking features by raw Wasserstein, which ranks them by their units. - Concluding "no drift" from an unchanged PSI when the change happened inside a bin.

  • Why is a raw Wasserstein drift score hard to compare across features?
    It is in each feature's units: the claimed amount gives currency, days since policy start gives days. A 2,000 move on amounts and a 2-day move on tenure are not comparable numbers. Dividing W1 by a reference spread — the standard deviation, or the interquartile range for a heavy tail — makes it unitless, so one scale can cover many numeric features.
  • What does taking the square root of Jensen–Shannon add for drift scoring?
    The square root, the Jensen–Shannon distance, is a true metric: besides symmetry it satisfies the triangle inequality, so distances among several windows behave geometrically. It stays bounded, at most √ln 2 ≈ 0.83 with natural logarithms or 1 with base-2 logarithms.

Picture each window as sand poured into a row of boxes along a ruler. PSI and Jensen–Shannon only count how much sand sits in each box compared with before. Wasserstein counts the shovelling: sand moved times the distance carried. Sand that slides further along inside the last, open-ended box changes no box's count, so the box-counters see nothing, yet the shoveller is charged for every metre.

  • Jensen–Shannon is bounded by 1 whatever logarithm base is used.
  • A PSI of 0.1 and a Jensen–Shannon of 0.1 mean the same drift.
  • Wasserstein-1 needs the same bins as PSI before it can be computed.
  • If no bin share changed, the claimed amounts cannot have moved.
  • Raw Wasserstein scores from different features can be ranked directly.