How do you score input drift on a categorical claim feature like intake channel when live traffic brings a value the reference never saw?
answer
- categories are already bins
- the largest single-category move
- an unseen bucket kept in the reference
- the floor's size drives that term
- no order, so no Wasserstein
basics
~20 sScore 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.
solid answer
~50 sEach category is its own bin, so compare shares per value. The L-infinity distance, `max |a_c − e_c|`, is the largest single-category change: easy to read on a dashboard, but blind to many small moves that add up; PSI or Jensen–Shannon give the overall shift. A value missing from the reference has no reference share: dropping it hides the shift, and `ln(a / 0)` makes PSI infinite. So when the reference is captured, add an explicit unseen/other bucket with a fixed, recorded floor. If phone goes 0.50→0.40, broker 0.30→0.25, web 0.20→0.20 and a mobile app arrives at 0.15, L-infinity is 0.15 and PSI is about 0.78 with a 0.001 floor but 1.13 with 0.0001: the floor is part of the score. Jensen–Shannon stays finite with no floor. Wasserstein needs an ordering, which peril types or channels do not have.
go deeper
Recall that each category is its own bin and that a value missing from the reference needs a home, or the score breaks.
Explain L-infinity versus PSI or Jensen–Shannon on category shares, the unseen bucket with a floor, and why Wasserstein needs an ordering categories lack.
Show that the floor sets the new category's PSI term, compute it, and handle high cardinality by folding rare values on the reference.
Standardise the unseen bucket, floor and folding rule across every categorical feature a platform scores, so scores stay comparable and new values never vanish.
## Categories are already bins A categorical input on a claims-triage model — peril type (water, fire, theft, storm), region, or intake channel (phone, broker, web form) — needs no bin edges: each value is a bin. For each window you compute the **share** of claims in each category, reference `e_c` and live `a_c`, and every drift score works on those shares. ## Two scores on the same shares - **L-infinity (Chebyshev) distance**: `max_c |a_c − e_c|`, the largest change in any single category's share. It reads plainly on a dashboard ("web form dropped 9 points") and is bounded by 1. - **PSI or Jensen–Shannon over the categories**: the same formulas as for numeric bins, adding every category's contribution. They notice many small moves that L-infinity ignores. L-infinity's blind spot is aggregation. If twenty regions each move two points — ten up, ten down — L-infinity is 0.02, while the total variation distance (half the sum of absolute changes) is 0.20. The two views answer different questions: "what is the biggest single change?" and "how different is the mix overall?". ## The value the reference never saw The case that breaks naïve code: the reference was captured before a mobile-app intake channel existed, and now it carries 15% of claims. | Channel | Reference share | Live share | Absolute change | PSI term (reference floor 0.001) | |---|---|---|---|---| | phone | 0.50 | 0.40 | 0.10 | 0.022 | | broker | 0.30 | 0.25 | 0.05 | 0.009 | | web form | 0.20 | 0.20 | 0 | 0 | | unseen / other (mobile app) | 0 → 0.001 | 0.15 | 0.15 | 0.747 | There are three ways to handle the new value: 1. **Drop it.** Score only categories present in the reference. The live shares are renormalised over the old channels, and the 15% that arrived through a new door vanishes from the score: the most important change is the one hidden. 2. **Keep it with a reference share of zero.** PSI's term contains `ln(0.15 / 0)`, so the score is infinite and the job fails or reports infinity. 3. **Reserve an unseen bucket.** When the reference is captured, add an explicit "unseen / other" category with a small fixed **floor** share. Every live value outside the reference vocabulary lands there and is scored. Option 3 is the sound design, with one cost to state honestly: **the floor's size sets the new category's term**. With a 0.001 floor the term is 0.149 × ln 150 ≈ 0.75 and PSI ≈ 0.78; with a 0.0001 floor it is 0.1499 × ln 1,500 ≈ 1.10 and PSI ≈ 1.13. The floor is therefore part of the score's definition: fix it once, record it with the reference, and keep it the same across features. L-infinity has no such sensitivity — it reads 0.15 either way — and Jensen–Shannon stays finite with no floor at all, about 0.056 nats here against its ceiling of ln 2. ## High cardinality A region feature with hundreds of values gives hundreds of bins, many holding only a handful of claims in a nightly window: - PSI's no-shift floor, roughly `(K − 1)(1/n + 1/m)` for K categories and window sizes n and m, climbs with the category count; - rare categories empty out in the live window and make PSI infinite. The usual remedy is to keep the categories that carry enough reference rows — a classical guide asks for about five expected rows per category in each window — and fold the rest into the "other" bucket. That folded list is decided on the reference and stored with it. ## Why not Wasserstein Wasserstein-1 measures how far mass travelled, so it needs a **distance between values**. Water, fire, theft and storm have none. Encoding them as 0, 1, 2, 3 invents one, and relabelling the codes changes the score. An **ordinal** count such as the policyholder's prior-claim count is different: zero, one, two, three prior claims are ordered and evenly spaced, so Wasserstein is meaningful there. ## Mistakes to avoid - Silently filtering live values that are not in the reference vocabulary. - Choosing a floor per run or per feature, which makes scores incomparable. - Reporting only L-infinity on a high-cardinality feature, where small moves add up unseen.
- Why can L-infinity alone miss categorical drift?It reports only the biggest single move. If twenty regions each shift two points, ten up and ten down, L-infinity reads 0.02 while total variation, half the sum of absolute changes, is 0.20. Pair it with PSI, Jensen–Shannon or total variation when the feature has many categories.
- How would you score drift on a region feature with 400 distinct values?Keep the categories with enough reference rows — about five expected rows per category in each window is a classical guide — and fold the rest into an other bucket defined on the reference. Hundreds of sparse categories raise PSI's no-shift floor, roughly (K − 1)(1/n + 1/m), and empty live categories make PSI infinite. Store the folded list with the reference.
- Dropping categories the reference never saw keeps the drift score clean.
- Encode peril types as integers and Wasserstein works as a drift score.
- The floor on an unseen bucket is too small to affect PSI.
- L-infinity catches every categorical shift that PSI catches.
- A new category's PSI term should simply be skipped as undefined.