skip to content

How is the population stability index (PSI) computed as a drift score for a claims-triage model's claimed-amount input?

level: juniorimportance: must knowfreq 62%

answer

  1. two windows, one set of bins
  2. edges cut on reference quantiles
  3. compare shares, not raw counts
  4. every bin term is non-negative
  5. a sum of both KL directions

basics

~20 s

Cut bins once at the reference window's quantiles and freeze them, take each bin's reference share e and live share a, and sum (a − e) · ln(a / e). Zero means identical shares; the score grows as claims move between bins.

solid answer

~50 s

Cut bin edges once on the reference window, at its quantiles (deciles for ten bins), so each bin holds about 10% of reference claims even though claimed amounts are heavy-tailed, and freeze those edges. For each window, count claims per bin and convert to shares: `e_i` for the reference, `a_i` for live. Then `PSI = Σ (a_i − e_i) · ln(a_i / e_i)`. Every term is non-negative, because the difference and the log always share a sign, and the sum equals KL(live‖ref) + KL(ref‖live), so swapping the windows gives the same number. With four quartile bins and live shares 0.15, 0.20, 0.25, 0.40, the terms are 0.051, 0.011, 0 and 0.071, so PSI ≈ 0.133. The score says that mass changed bins, not how far it moved, and it is undefined when a bin share is zero.

code

pseudocode · 20 lines
pseudocode
# once, when the reference is captured
edges = quantiles(reference_amounts, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
floor = 0.0001
store_with_reference(edges, floor)

function bin_shares(values, edges):
    counts = zeros(length(edges) + 1)
    for v in values:
        counts[bin_index(v, edges)] += 1   # first and last bins are open-ended
    return [c / length(values) for c in counts]

function psi(reference_values, live_values, edges, floor):
    e = bin_shares(reference_values, edges)
    a = bin_shares(live_values, edges)
    total = 0
    for i in 0 .. length(e) - 1:
        ei = max(e[i], floor)
        ai = max(a[i], floor)
        total += (ai - ei) * ln(ai / ei)
    return total

go deeper

for a junior

Recall the recipe in order: bin edges from the reference, shares per window, then the sum of (live minus reference) times the log of their ratio. Be ready to compute one bin's term by hand.

for a middle

Explain why the edges are reference quantiles and frozen, why every term is non-negative, and why the score is symmetric: it is both KL directions added together.

for a senior

Show where PSI misbehaves: an empty bin makes it infinite, small windows inflate it with nothing moved, and it cannot see values moving further inside one bin.

for a principal

Treat edges, bin count and floor as part of the score's definition, versioned with the reference, so scores stay comparable across models, features and months.

## What PSI is for The **population stability index (PSI)** is the most widely used single number for "has this model input moved since we captured the reference?". Take a claims-triage model that routes each new property-insurance claim to fast-track, adjuster review or the special-investigations unit. The **claimed amount** is a natural first input to watch: numeric, heavy-tailed, and decisive for routing. PSI compares two samples of that one feature — the **reference window** (claims captured once, typically the ones the model was validated on) and a **live window** (recent claims) — and turns their difference into one non-negative score. ## Step 1: cut the bins on the reference, then freeze them PSI works on **bin shares**, so the first decision is where the bin edges go. - **Cut them on the reference.** Compute the reference's quantiles — deciles for ten bins — and use those values as edges, so each bin holds about 10% of reference claims. - **Use quantiles, not equal widths, for a heavy tail.** Claimed amounts can run from a few hundred to a few million. Equal-width bins across that range put almost every claim in the first bin or two and leave the rest nearly empty; quantile edges spread the reference evenly, so every bin carries enough rows to estimate a share. - **Make the outer bins open-ended.** The first bin is "below the 10th percentile" and the last "above the 90th", so every live value lands somewhere, including amounts larger than anything in the reference. - **Freeze the edges.** Store them with the reference and reuse them for every live window. Re-cutting quantiles on each live window puts 10% of live claims in every bin by construction, and PSI then reads near zero whatever happened. ## Step 2: shares and the formula For each window, count claims per bin and divide by that window's size, giving reference shares `e_i` and live shares `a_i`. Shares, not counts, because the two windows differ in size. Then `PSI = Σ_i (a_i − e_i) · ln(a_i / e_i)` Three properties follow directly: 1. **Every term is non-negative.** When `a_i > e_i` both factors are positive; when `a_i < e_i` both are negative. PSI is never below zero, and each bin can only add to it. 2. **It is symmetric.** The sum equals KL(live ‖ reference) + KL(reference ‖ live) — the symmetrised form known as the **Jeffreys divergence** — so swapping the two windows gives the same number. (KL, the Kullback–Leibler divergence, is a directed measure of how one distribution differs from another.) 3. **It is undefined with an empty bin.** If a live share is zero the log is of zero; if a reference share is zero the ratio divides by zero. Practical jobs therefore fix a floor or pseudocount in advance and store it with the edges. ## A worked example Four quartile bins on the reference, so each `e_i = 0.25`. Overnight the live shares come out 0.15, 0.20, 0.25 and 0.40: mass has moved toward large claims. | Bin | e | a | a − e | ln(a / e) | Term | |---|---|---|---|---|---| | lowest quarter | 0.25 | 0.15 | −0.10 | −0.511 | 0.051 | | second quarter | 0.25 | 0.20 | −0.05 | −0.223 | 0.011 | | third quarter | 0.25 | 0.25 | 0 | 0 | 0 | | top quarter | 0.25 | 0.40 | +0.15 | +0.470 | 0.071 | | **PSI** | | | | | **≈ 0.133** | The two KL directions come out at about 0.067 and 0.066; they add to the same 0.133. ## Reading the number - **Above zero even when nothing moved.** Two samples from the same distribution still differ by chance, so PSI sits slightly above zero on unshifted data; how far depends on the bin count and the window sizes. - **It says that mass moved between bins, not how far.** A claim that grows from 60,000 to 600,000 inside the open top bin changes no share and adds nothing to PSI. - **Its scale is its own.** A PSI value is not comparable with a Jensen–Shannon or Wasserstein value, and the cutoff for acting on it belongs to the separate question of where drift thresholds come from. ## Common mistakes - Re-cutting quantile edges on each live window, which hides the very shift being measured. - Feeding raw counts instead of shares, which breaks as soon as the two windows differ in size. - Treating the bin count and the floor as knobs to retune later. They are part of the score's definition, versioned with the stored reference, so that this month's PSI is comparable with last month's.

  • Why cut the PSI bin edges on the reference rather than re-cutting them on each live window?
    Quantile edges re-cut on the live window put about 10% of live rows in every bin by construction, so live shares always match and PSI reads near zero whatever moved. Frozen reference edges are a fixed ruler: a live share departs from 10% only because the distribution moved or by sampling noise. Storing the edges with the reference also keeps today's score comparable with last month's.
  • Why quantile bins rather than equal-width bins for a heavy-tailed claimed amount?
    Equal-width bins over a range from hundreds to millions put nearly every claim in the first one or two bins and leave the rest almost empty. The score then sees little of the bulk, and its sparse tail bins are noisy or empty. Quantile edges give each bin a similar reference share, so every bin carries enough rows to estimate a share and changes anywhere in the bulk register.
  • How many bins should a PSI drift score use?
    Common practice is roughly 10 to 20, chosen so every bin keeps enough expected rows; a classical rule asks for about five per bin in both windows, ten in the tails. More bins resolve finer changes but raise the score's no-shift floor, roughly (B − 1)(1/n + 1/m), and make empty live bins likelier. Fix B with the edges: scores over different bin counts are not comparable.

  • PSI changes when you swap which window is the reference and which is live.
  • Re-cut the quantile bins on each live window so every bin stays well filled.
  • PSI can come out negative when the live window shifts toward smaller values.
  • Raw bin counts can go into the PSI formula without converting them to shares.
  • PSI is exactly zero whenever the claim population has not changed.
  • PSI says how far, in currency, the claimed amounts moved.