CSC3119 Β· Module 8 of 9

Observability, Covariate Drift & Population Stability Index (PSI)

Detect data distribution changes and performance degradation before models fail patients

~56 min to study properly

Software systems fail visibly with stack traces and crash logs. Machine learning models fail silently: the API continues returning HTTP 200 with clean JSON, but predictions quietly lose real-world validity.

Checkpoint Β· the examiner asks

Define Data Drift versus Concept Drift with clinical examples, and explain how the Population Stability Index (PSI) is calculated and interpreted.

In one minute

ML fails silently: HTTP 200, wrong answers. Data drift is a change in P(X); concept drift is a change in P(Y|X). PSI bins a feature and sums (A βˆ’ E)Β·ln(A/E) across bins: < 0.1 stable, 0.1–0.25 monitor, β‰₯ 0.25 retrain and recalibrate. Monitor inputs and outputs continuously, not just uptime.

Traps examiners look for
  • Using log base 10 instead of the natural log in PSI.
  • Treating a PSI of 0.18 as 'retrain now' β€” it's the monitor band.
  • Confusing data drift with concept drift.
Read

Study notes

01Models fail silently

Ordinary software fails loudly: exceptions, stack traces, 500 errors. ML models usually fail silently: the API keeps returning HTTP 200 with well-formed JSON, latency is fine, dashboards are green β€” and the predictions are steadily getting worse because the world has changed since training.

So ML monitoring has two layers:

  • Service health β€” uptime, latency, error rates (same as any API).
  • Model health β€” are the inputs still like the training data? Are the outputs behaving as expected? When labels arrive later (did the patient have a stroke?), is accuracy holding?

02Data drift vs concept drift

  • Data drift (covariate shift) β€” the distribution of inputs P(X) changes. The hospital opens a geriatric wing; patient ages shift up. The relationship between features and stroke may be unchanged, but the model now sees regions of feature space it rarely saw in training.
  • Concept drift β€” the relationship P(Y | X) changes. A new treatment lowers stroke risk for hypertensive patients; the same inputs now mean something different.

Data drift can be detected immediately from inputs alone. Concept drift needs ground-truth labels, which arrive with a delay, so you monitor proxies (prediction distribution, rate of high-risk flags) and evaluate properly when labels come in.

03Population Stability Index (PSI)

PSI compares a feature's production distribution with its training (reference) distribution:

  1. Split the reference data into bins β€” usually 10 quantile bins, so each holds E = 10% of training rows.
  2. Count the share A of production rows that fall in each of those same bins.
  3. PSI = Ξ£ (A βˆ’ E) Β· ln(A / E) over all bins (natural log).

Each term is β‰₯ 0 and grows when a bin gains or loses share, so PSI is 0 when the distributions match. Industry rule of thumb:

PSIMeaningAction
< 0.10stablenone
0.10 – 0.25moderate shiftinvestigate, monitor closely
β‰₯ 0.25significant shiftretrain and recalibrate

Practical details: use a small floor (e.g. 0.0001) so empty bins don't give ln(0); compute PSI per feature on a rolling window large enough to be stable.

04From detection to retraining

A monitoring pipeline for the stroke model:

  1. Log every request's features and prediction (with privacy controls).
  2. Each day, compute PSI per feature against the training reference, plus the distribution of predicted risk; the KS test is a common alternative for continuous features.
  3. Alert in the 0.10–0.25 band; trigger retraining at β‰₯ 0.25 or when evaluation on newly labelled cases shows recall dropping.
  4. Retrain on recent data, re-validate (recall at the clinical threshold, calibration), and release via canary β€” never auto-deploy a retrained model straight to 100%.

PSI says that something changed, not whether it matters. A big shift in an unimportant feature may not hurt; a small shift in the most important one might. Pair drift metrics with feature importance and, when labels arrive, real performance.

Watch it done

Worked examples

Worked example 1

PSI for one bin

In the age bin 60–70, the training share is E = 0.10 and this month's share is A = 0.22. What does this bin contribute to PSI?

    Worked example 2

    A full PSI calculation

    With 4 bins (E = 0.25 each), production shares are 0.20, 0.25, 0.25, 0.30. Compute PSI and decide.

      Vocabulary

      Key terms

      Evidently AI & Prometheus in Production

      Modern MLOps stacks export statistical drift metrics (PSI, Wasserstein distance, KS p-values) from Evidently AI directly into Prometheus and Grafana dashboards, firing automated Slack/PagerDuty alerts before degraded model predictions affect patients.

      Practise

      Quick check

      0 of 8 correct so far. Wrong answers come with an explanation β€” and the buddy can unpack them.

      Q1In a production monitoring dashboard, the PSI for patient glucose distribution over the last 30 days is measured at 0.32. What action should be taken?

      Q2During COVID-19, patient symptoms and travel patterns changed radically, altering how ML models predicted respiratory risk. What type of drift is this?

      Q3Data drift (covariate shift) is a change in…

      Q4What does PSI = 0.18 suggest?

      Q5Which log is used in PSI?

      Q6Why do ML models 'fail silently'?

      Q7Detecting concept drift requires…

      Q8E = 0.10, A = 0.10 in a bin. Its PSI contribution is…

      Exam-style

      Written practice

      Short answer5 marks

      Distinguish data drift from concept drift with a hospital example of each.

      Short answer6 marks

      Explain how PSI is calculated and the thresholds used to act on it.

      Long answer12 marks

      Design the monitoring and retraining system for the stroke model in production. Cover what is logged, which metrics are computed and how often, alert and retraining thresholds, how delayed labels are used, and how a retrained model reaches production safely.

      Watch

      Videos

      Fresh picks are chosen by AI every day.
      Hands-on

      Population Stability Index (PSI) & Covariate Drift Detector

      4 guided tasks: predict, experiment, explain β€” then challenge yourself. Plus 1 coding exercise you run right in the browser.

      Start the lab