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?
answer
- too many bins for the window
- six expected claims per bin
- noise floor ~ (B−1)(1/n+1/m)
- an empty live bin: ln of zero
- fewer bins, merge, smooth, or JS
basics
~20 sFifty 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.
solid answer
~50 sBoth symptoms come from too many bins for the window. Under no shift PSI behaves like a chi-square with `B − 1` degrees of freedom scaled by `(1/n + 1/m)`, so its expected value is about `(B − 1)(1/n + 1/m)`: with a 50,000-claim reference that is ≈ 0.164 for 50 bins on 300 claims, against ≈ 0.030 for 10 bins. Each bin expects 300 × 0.02 = 6 live claims, so a given bin is empty with probability 0.98³⁰⁰ ≈ 0.0023, and across 50 bins at least one is empty on roughly one night in nine; its `ln(a / e)` term is then infinite. Fixes: fewer bins so each keeps about five expected rows (ten in the tails), merge sparse reference bins, add a fixed recorded pseudocount, or switch to Jensen–Shannon, which stays finite but still reads above zero with nothing moved.
go deeper
Recall that PSI needs every bin populated and that it reads above zero even when nothing moved.
Explain the no-shift level (B − 1)(1/n + 1/m), why an empty live bin makes PSI infinite, and how additive smoothing works.
Diagnose both symptoms as one cause, compute the expected floor and the empty-bin odds, and fix bin count, merging or smoothing rather than patching with an ad-hoc epsilon.
Set a platform rule tying bin count to the smallest window a job scores, with the floor recorded as part of each score's definition.
## Two symptoms, one cause A claims-triage model's drift job computes PSI for *days since the policy started*. The reference holds 50,000 claims; each night's live window holds about 300. Edges were cut at 50 reference quantiles, so every bin holds 2% of the reference. On nights when nothing changed, PSI reads around 0.16, give or take a few hundredths, and on roughly one night in nine it returns infinity. Both symptoms come from one mismatch: **50 bins is too many for 300 live rows**. Each bin expects 300 × 0.02 = **6 claims**. ## Why PSI reads high when nothing moved Two samples from the same distribution never have identical bin shares, and every PSI term is non-negative, so sampling noise can only push the score up. Under no shift PSI is approximately a chi-square variable with `B − 1` degrees of freedom scaled by `(1/n + 1/m)`, where B is the bin count and n and m are the window sizes. Its expected value is therefore about `(B − 1) · (1/n + 1/m)` | Bins B | Live window m | Expected live rows per bin | Expected PSI, nothing moved | |---|---|---|---| | 10 | 500 | 50 | ≈ 0.018 | | 10 | 300 | 30 | ≈ 0.030 | | 10 | 100 | 10 | ≈ 0.090 | | 50 | 300 | 6 | ≈ 0.164 | The reference is 50,000 throughout; its 1/n term is tiny next to the live window's 1/m. The approximation itself assumes enough rows per bin — a classical rule asks for about five expected rows in every bin of both windows, ten in the tails — so at six per bin it is a rough guide. The direction is reliable: **more bins or a smaller window raises the floor**. Any cutoff tuned at one combination means something different at another; where that cutoff should come from is a separate question about drift thresholds. ## Why it sometimes returns infinity PSI's term for bin i is `(a_i − e_i) · ln(a_i / e_i)`. If no live claim falls in bin i, `a_i = 0` and the log of zero makes the term, and the score, infinite. With six expected claims the chance that a given bin is empty is 0.98³⁰⁰ ≈ 0.0023; across 50 bins at least one is empty on about 11% of nights, with nothing having moved. An infinite PSI therefore means "one bin was empty", not "the feature changed completely". ## Fixes, in order of preference 1. **Fewer bins.** Ten bins over 300 claims gives 30 expected per bin, an expected no-shift PSI near 0.030, and a negligible chance of an empty bin. Choose B so every bin keeps enough expected rows in the smaller window. 2. **Merge sparse bins on the reference.** Where the tails thin out, join adjacent bins until each meets the minimum count, and store the merged edges with the reference. 3. **Smooth with a fixed pseudocount.** Additive smoothing adds α to every bin's count in both windows, `(count + α) / (N + Bα)`, pulling shares slightly toward uniform; ½ and 1 are classic choices. It keeps every share positive but changes the score, so α is fixed, recorded and identical everywhere. 4. **Switch to Jensen–Shannon.** It compares each window with their average, so it stays finite with a one-sided empty bin, and it is bounded by ln 2 in nats. It is not immune to the first symptom: with nothing moved it also reads above zero, about one-eighth of PSI's level on the same bins. A longer live window is the other lever; choosing the window belongs to the design of the drift check, not to the score. ## What not to do - **Replace zero shares with an epsilon picked on the spot.** An empty live bin with a 2% reference share then contributes about 0.02 × ln(0.02 / ε): ≈ 0.20 at ε = 10⁻⁶ and ≈ 0.29 at ε = 10⁻⁸. The epsilon, not the data, sets the score. - **Drop empty bins from the sum**, which deletes exactly the mass that moved. - **Add bins to "sharpen" the score.** Narrower bins raise the noise floor and make empty bins likelier still. - **Compare scores across features with different bin counts or window sizes** as if they shared a scale.
- Why not just replace zero shares with 1e-6 and move on?An empty live bin with a 2% reference share then contributes about 0.02 × ln(0.02 / 1e-6) ≈ 0.20 — more than the whole no-shift floor of a well-sized job — and about 0.29 with 1e-8. The floor's size, not the data, sets the score. If a floor is used, fix it once, record it with the reference and keep it identical across features and runs.
- Does switching to Jensen–Shannon remove the small-window inflation?No. Jensen–Shannon stays finite with a one-sided empty bin and is bounded by ln 2 in nats, but on unshifted data it still reads above zero — about one-eighth of PSI's level on the same bins and samples — and that level still rises with more bins and smaller windows. It fixes the infinity, not the sample-size bias.
- What do you give up by merging sparse bins?Resolution where the merged bins were: a shift that moves claims between two now-merged tail bins no longer registers. That is usually the right trade, because those bins were too sparse to estimate a share reliably anyway, and a score that is noise in the tails cannot detect a tail shift either.
- A PSI of 0.16 on a quiet night proves the inputs genuinely moved.
- More bins always make a PSI drift score more accurate.
- An epsilon floor fixes empty bins without affecting the score.
- Jensen–Shannon removes the small-window inflation PSI suffers from.
- An infinite PSI means the feature's distribution changed completely.