Population Stability Index
Population Stability Index
The Population Stability Index (PSI) quantifies how much a feature's distribution has shifted between a reference (training) dataset and a current (production) dataset. It is a standard metric in credit risk and ML monitoring.
where and are the proportions of observations in bin for the reference and current datasets respectively.
Interpretation: PSI < 0.1 → stable; 0.1–0.25 → moderate shift; > 0.25 → major shift.
You are given pre-computed bin proportions (already summing to 1.0 each) — no binning required.
Numerical stability: Replace any zero proportion with a small constant eps = 1e-4 before computing the log.
Example:
expected = [0.5, 0.5] actual = [0.5, 0.5] PSI = 0.0 (identical distributions)
Your task:
Implement compute_psi(expected_proportions, actual_proportions) returning a single float.
Example Tests
Identical distributions: PSI is 0.0
Input: {"actual_proportions":[0.5,0.5],"expected_proportions":[0.5,0.5]}
Expected: 0
Small shift: PSI should be positive and less than 0.1
Input: {"actual_proportions":[0.35,0.4,0.25],"expected_proportions":[0.4,0.4,0.2]}
Expected: 0.00641
Swapped proportions: PSI is symmetric so same value both ways
Input: {"actual_proportions":[0.7,0.3],"expected_proportions":[0.3,0.7]}
Expected: 0.56212