skip to content

questions

27

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.
open as a page

An inbound spam filter is live but no message has a confirmed verdict yet - which signals can you chart today?

level: juniorimportance: must knowfreq 68%

basics

~20 s

Everything the model saw and emitted is available immediately: per-feature summary statistics and null rates, the prediction-score histogram, the blocked rate at the current decision cutoff, and traffic volume - each cut by tenant, inbound path and language.

open as a page

A predictive-maintenance model predicts failure within 30 days - why does this week's precision chart read optimistically high, and what corrects it?

level: middleimportance: must knowfreq 76%

basics

~20 s

Recent cohorts are still right-censored: a failure resolves the moment it happens while survival is only confirmed at day 30, so dropping unresolved rows over-counts failures. Bucket the metric by prediction date, publish only matured cohorts, and restate as labels land.

open as a page

In an inbound spam filter, why is the prediction-score histogram the first label-free signal most designs watch?

level: middleimportance: must knowfreq 60%

basics

~20 s

It compresses every input the model uses into a single curve the system already produces, so a change in any feature - including ones nobody thought to chart - can show up as a changed shape, for the cost of one series and no labels.

open as a page

A weather-feature shift test trips daily while served forecast error is unchanged - should that test page the on-call?

level: middleimportance: must knowfreq 57%

basics

~20 s

No. The pager belongs to the served forecast error, the effect the operator feels. A feature whose distribution moved without moving error is a diagnostic: attach it to the quality page as context, and let it file a ticket at most.

open as a page

Why does a drift test whose reference window rolls forward with recent traffic miss the slow shift it should catch?

level: middleimportance: must knowfreq 66%

basics

~20 s

A rolling reference re-estimates normal from data that already contains the drift, so each week's comparison is against last week's already-moved distribution. Gradual movement never accumulates in the statistic, though a step change still trips it.

open as a page

Technicians repair every asset the 30-day failure model flags, so it never fails - why does the label pipeline then record those flags as false positives?

level: seniorimportance: must knowfreq 64%

basics

~20 s

Maintenance destroyed the counterfactual. The alert caused a repair, no failure event was written inside the window, and a pipeline that equates 'no failure recorded' with 'negative outcome' books a prevented failure as a false positive.

open as a page

For a grid operator's intraday load forecast, which number should the single paging model-quality alarm be tied to?

level: seniorimportance: must knowfreq 66%

basics

~20 s

Tie it to the error of the forecast actually published, in megawatts against settled actuals, scored per forecast horizon. Not the offline validation loss, and not a per-feature shift statistic - neither one moves when the operator starts paying.

open as a page

Where should the alert threshold on a drift statistic like PSI come from, if not the conventional 0.1 and 0.25 bands?

level: seniorimportance: must knowfreq 57%

basics

~20 s

From a backtest on closed past seasons: replay the statistic over the same windows and pick the value that separated seasons where forecast error actually rose from seasons where it did not. The 0.1 and 0.25 bands are convention inherited from another domain.

open as a page

In a weekly input-drift check on a deployed crop-yield model, what must have been stored in advance?

level: juniorimportance: should knowfreq 50%

basics

~20 s

A reference: a sample of the training inputs or their per-feature summaries, produced by the same feature code as production and pinned to the model version. The live detection window is the only side production supplies for free.

open as a page

Instead of waiting 30 days for a breakdown, a team labels its failure model from closed maintenance work orders - how does that proxy lie?

level: middleimportance: should knowfreq 52%

basics

~20 s

A work order records that maintenance happened, not that an asset was failing. Alerts cause orders, preventive work opens them on healthy assets, coverage is incomplete, and closure timestamps are paperwork dates rather than fault times.

open as a page

How do you score input drift on a categorical claim feature like intake channel when live traffic brings a value the reference never saw?

level: middleimportance: should knowfreq 38%

basics

~20 s

Score per-category shares: L-infinity gives the largest single-category change, PSI or Jensen–Shannon the overall shift. Keep an explicit unseen bucket in the reference with a small, fixed floor, so a new mobile-app channel is scored rather than dropped.

open as a page

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%

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.

open as a page

Which input checks should gate an inbound spam filter's nightly retrain, and what should each one do when it fails?

level: middleimportance: should knowfreq 46%

basics

~20 s

Four deterministic checks against a frozen, reviewed spec of valid input: schema, range and allowed values, per-feature null ceilings, and freshness of the newest event. A hard failure stops the retrain, keeping the current model serving; a minor breach warns.

open as a page

A crop-yield model is scored weekly from imagery with a five-day revisit, so how often should its input shift test run?

level: middleimportance: should knowfreq 43%

basics

~20 s

At the rate the inputs genuinely refresh and the team could act on a result, which here is weekly, triggered by the feature partition landing rather than by a clock. Testing daily re-tests the same imagery and multiplies correlated firings.

open as a page

Only flagged machines get inspected, so misses stay invisible - how do you design a sample that estimates the failure model's false-negative rate?

level: seniorimportance: should knowfreq 41%

basics

~20 s

Draw a random sample of unflagged assets stratified by score band with known inclusion probabilities, inspect it, then weight each find by the inverse of its stratum's sampling rate to estimate misses across the whole fleet.

open as a page

When monitoring a claims-triage model's 384-dimension text embedding for input drift, why does a separate score per dimension mislead, and what replaces it?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Per-dimension scores raise chance alarms across 384 coordinates unless corrected, and they miss shifts in how dimensions co-vary. Score the vectors jointly: MMD with a permutation null, a domain classifier's held-out AUC, or reduced views such as PCA reconstruction error.

open as a page

A drift job computes the population stability index (PSI) over 50 quantile bins on 300-claim nightly windows; it reads high on quiet nights and sometimes returns infinity — why?

level: seniorimportance: should knowfreq 32%

basics

~20 s

Fifty bins over 300 claims leave about six expected claims per bin. Sampling noise alone gives PSI ≈ (B − 1)(1/n + 1/m) ≈ 0.16, and an emptied bin's ln(0) makes it infinite. Use fewer or merged bins, a fixed pseudocount, or Jensen–Shannon.

open as a page

An inbound spam filter's blocked rate falls from 12% to 10% overnight with no deploy and no errors, while one feature's null rate jumps to 22% - what happened?

level: seniorimportance: should knowfreq 52%

basics

~20 s

An upstream feature source degraded and its missing values are being filled with a default, so about a fifth of messages are scored without their strongest evidence. Nothing errors, because a default is a legal value, and detection quietly falls.

open as a page

Why does a multi-tenant spam filter cut its null-rate and score series per tenant instead of watching the aggregate?

level: seniorimportance: should knowfreq 44%

basics

~10 s

Aggregates fail in both directions: a small tenant's total breakage is diluted into noise, and the global curve can move purely because the mix of traffic changed while no tenant's mail changed at all.

open as a page

A three-day heatwave doubles intraday load forecast error and pages the on-call nightly - how should the alarm be redefined?

level: seniorimportance: should knowfreq 46%

basics

~20 s

Alarm on skill against a seasonal-naive baseline scored on the same intervals rather than on an absolute error level. A heatwave degrades the baseline too, so the ratio moves little, while a genuine model failure pushes it up.

open as a page

Why can a national input drift test read flat while one agro-climatic region's features have clearly moved?

level: seniorimportance: should knowfreq 41%

basics

~20 s

Pooling weights every region by its share of rows, so a region holding 4% of scored fields can move its whole distribution and contribute only a few hundredths to the national statistic — under any sensible threshold.

open as a page

A KS test over two million scored field-weeks flags a shifted input band at p<0.001, so why is that not yet an incident?

level: seniorimportance: should knowfreq 48%

basics

~20 s

At that row count almost any difference is significant, so the p-value reports that the movement is not sampling noise and says nothing about its size. Significance is not harm: read the effect size, then how much the model uses that input.

open as a page

What must a load forecaster's night runbook pre-decide so an on-call engineer can roll back the model version alone?

level: principalimportance: should knowfreq 44%

basics

~20 s

Three things: the trigger that counts as evidence, the target to fall back to - the previous model version or the non-learned baseline - and the authority, meaning the responder may switch without approval because the switch is reversible and expires.

open as a page

What change can leave a spam filter's input summaries and score histogram both unmoved while the model is already wrong?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

A change in the relationship between inputs and outcomes: the same-looking messages become malicious. Label-free signals watch the distribution of inputs and of scores, never the truth attached to them, so both curves hold their shape.

open as a page

A load forecaster's model-quality alarm fires at 03:00 - what decides whether it pages now or waits until morning?

level: seniorimportance: nice to knowfreq 31%

basics

~20 s

The time until the next irreversible commitment on that forecast horizon, not the size of the error. Intraday forecasts are dispatched on continuously, so they page; a day-ahead forecast is only committed at gate closure hours later.

open as a page

Plant leadership wants one monthly quality number for the 30-day failure model while most of the month's predictions are unresolved - what do you publish, and what do you commit to?

level: principalimportance: nice to knowfreq 31%

basics

~20 s

Publish the last fully matured cohort as the official figure, plus a clearly marked provisional estimate carrying an interval and a maturity percentage, and commit to a restatement policy that says when a number becomes final and who is told when it moves.

open as a page