Population Stability Index (PSI) & Covariate Drift Detector
The hospital opens a geriatric wing. Shift the production age distribution and compute the real Population Stability Index, bin by bin — then decide whether to retrain.
Predict first
Commit to a guess before you touch anything. Being wrong here is how it sticks.
One bin: expected E = 0.10, actual A = 0.24. What is its PSI contribution (4 dp)?
Experiment
Move the controls and watch the outputs. Goals tick off automatically when you reach them.
PSI on patient age (10 reference deciles)
Training ages ~ Normal(52, 15). Each decile holds 10% of training patients.
| Decile | E | A | (A−E)·ln(A/E) |
|---|---|---|---|
| 1 | 0.100 | 0.100 | 0.0000 |
| 2 | 0.100 | 0.100 | 0.0000 |
| 3 | 0.100 | 0.100 | 0.0000 |
| 4 | 0.100 | 0.100 | 0.0000 |
| 5 | 0.100 | 0.100 | 0.0000 |
| 6 | 0.100 | 0.100 | 0.0000 |
| 7 | 0.100 | 0.100 | 0.0000 |
| 8 | 0.100 | 0.100 | 0.0000 |
| 9 | 0.100 | 0.100 | 0.0000 |
| 10 | 0.100 | 0.100 | 0.0000 |
Explain it
Put what you saw into words. This is what the exam will ask you to do.
How does PSI measure covariate drift, what thresholds do we use, and how is this different from concept drift?
Code it
Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.
Population Stability Index
Write psi(expected, actual, bins=10):
- Bin edges are the quantiles of
expected(deciles for bins=10), with the outer edges widened to ±infinity so every production value lands in a bin. - E and A are the shares of
expectedandactualin each bin. Floor both at1e-4to avoidln(0). - Return Σ (A − E) · ln(A / E).
Then classify drift for the scenarios below with drift_level(value) → "stable" (< 0.1),
"monitor" (0.1–0.25) or "retrain" (≥ 0.25).
Challenge
Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.
Population Stability Index (PSI) Bin Contribution
In baseline training data, age bin [60–70] contained 20% of patients (E = 0.20). In recent production traffic, this bin jumped to 32% (A = 0.32). What is the PSI contribution of this single bin: (A − E) × ln(A / E)? (3 decimals)