advanced25 min studyLesson 871 in Engineering

Monitor feature populations before interpreting a drift score

Define reference populations, missing-value buckets, feature summaries, and joint checks that make an input-distribution alert interpretable.

On this page

What you’ll understand

  • Calculate categorical distribution distances on a common support.
  • Separate population changes from missingness and sampling changes.
  • Explain why unchanged marginal summaries do not establish an unchanged joint distribution.

A feature monitor compares populations, not merely arrays with matching column names. A change in customer geography, a broken join, and a different logging sample can produce similar histograms while requiring different responses. Establish the population, time window, sampling rule, and feature transformation before computing a distance. An input alert then identifies a discrepancy worth investigating; it does not by itself establish that the deployed model has become less accurate.

Make the reference population reproducible

Store the reference dataset identifier, capture interval, eligibility rules, sampling probabilities, schema, and transformation version with its statistics. Comparing a weekday production window with an unbalanced weekend training sample can mostly measure a known calendar effect. Maintain a stable training reference for deployment mismatch and a recent, seasonally appropriate production reference for operational changes. These answer different questions. A rolling reference alone can absorb a slow degradation until each adjacent comparison appears small, so preserve the historical context needed to recognize accumulated movement.

Count the requests that should have been captured as well as the records that arrived. Sampling after a successful response excludes failures; sampling one request per session differs from sampling every request. If logging probabilities differ across groups, either define the target as the captured population or use justified inclusion weights and report their support. Data minimization can restrict what is retained, but a feature summary without its population contract cannot distinguish changed behavior from changed observation. Track duplicate identifiers and capture gaps beside distribution statistics.

p^j=njN,∑j=1Jp^j=1,N=∑j=1Jnj>0\widehat p_j=\frac{n_j}{N},\qquad \sum_{j=1}^{J}\widehat p_j=1,\qquad N=\sum_{j=1}^{J}n_j>0
The J mutually exclusive, exhaustive buckets include missing and unknown values when applicable. Counts refer to one explicitly defined captured population; proportions are dimensionless. An empty window has no defined empirical distribution.↔ Scroll wide equations horizontally.

Use stable supports and inspect what moved

For categorical features, align both windows to the union of named categories, including new categories with zero reference count. Total variation summarizes the amount of probability mass that would have to move to match the histograms. Keep the largest category contributions so the aggregate distance remains explainable. Numeric bins need fixed, versioned boundaries and declared underflow, overflow, missing, and nonfinite policies. Recomputing quantile boundaries independently in each window can hide a physical scale change by giving every new bin approximately equal occupancy.

Missingness deserves its own denominator and breakdown by upstream source. A mean computed only over present values can remain constant while half the requests lose a feature. Monitor valid count, missing fraction, ranges, and selected quantiles together rather than treating one statistic as a complete detector. Distances calculated from finite samples also fluctuate under an unchanged population. An operational threshold should reflect sample size, expected seasonality, investigation cost, and model sensitivity; the value of a distance is not automatically a calibrated probability of harm.

TV⁡(p^,q^)=12∑j=1J∣p^j−q^j∣∈[0,1]\operatorname{TV}(\widehat p,\widehat q)=\frac12\sum_{j=1}^{J}|\widehat p_j-\widehat q_j|\in[0,1]
Both empirical categorical distributions use the same exhaustive support and positive denominators. This dimensionless descriptive distance has no built-in false-alarm or accuracy guarantee.↔ Scroll wide equations horizontally.

Marginal checks leave interaction blind spots

Two binary features can each remain balanced while their relationship reverses. If the reference contains only equal pairs and the current population contains only unequal pairs, both individual histograms are unchanged but their joint support is different. Add selected cross-feature checks where the model or domain suggests meaningful interactions. Multivariate representations and two-sample procedures can help, but their sensitivity depends on the representation and available examples. A learned embedding can discard exactly the distinction that a downstream decision needs, so passing an embedding monitor is limited evidence.

The sampling instrument isolates ordinary proportion uncertainty. Reset, set p=0.20 and n=25, predict mean 0.20 and sample-mean variance 0.0064, then Play or Step. Separately Reset, set p=0.20 and n=100, predict the same mean and variance 0.0016, then Play or Step. Playback highlights exact binomial outcomes rather than collecting data. This comparison motivates recording sample size, while providing no multivariate detector, seasonal adjustment, or missing-data correction. Production interpretation still requires tracing the changed categories to their originating requests.

Explain a three-category movement

A fixed reference has 1,000 requests split across categories A, B, and C as 500, 300, and 200. A current window of 1,000 contains 300, 400, and 300, with identical capture rules and no missing values. Compute total variation and the largest contribution.

  1. Normalize the counts: the reference proportions are (0.50,0.30,0.20), and the current proportions are (0.30,0.40,0.30). Equal totals make the comparison simple but are not required by the definition.

  2. Take absolute category differences: 0.20, 0.10, and 0.10. Their sum is 0.40, so total variation is 0.20.

  3. Category A supplies the largest absolute difference, 0.20. Its share fell twenty percentage points; B and C each rose ten. Inspect the source population and model sensitivity before attributing any performance change.

The result

The descriptive movement is TV=0.20. It is neither a twenty-percent accuracy loss nor a p-value.

Explore the model

Interactive lab

Interactive lab · sampling

Window size changes proportion variability

Reset, set p=0.20 and n=25, predict mean 0.20 and variance 0.0064, then Play or Step. Separately Reset, set p=0.20 and n=100, predict variance 0.0016, then Play or Step. Exact iid Bernoulli sample-mean masses are displayed; playback only highlights outcomes. This is not a drift test or multivariate monitor.

Window size changes proportion variabilityExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA feature proportion needs a population definition and sample-size context.

Check your understanding

Both binary-feature marginals are unchanged. What follows about their joint distribution?

Try it yourself

A reference has 900 present and 100 missing values; a current window has 700 present and 300 missing. Both windows contain 1,000 requests. Find the two-bucket total variation and explain why comparing present-value means alone is insufficient.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Treat present and missing as an exhaustive categorical distribution.

Compare with the solution

The distributions are (0.9,0.1) and (0.7,0.3), so TV=(0.2+0.2)/2=0.20. The missing fraction rose from 10% to 30%. Present-value means omit those missing requests and can remain unchanged despite a large coverage loss; investigate the feature source and affected decision paths.

Take it with you

  • Reference populations and capture rules are part of the monitoring artifact.
  • Include missingness and use common categorical supports or fixed numeric bins.
  • Unchanged marginals and small distances do not prove model performance is stable.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.