Construct a test that preserves the intended separation and sampling design
Build evaluation records from a documented population frame, keep related entities across split boundaries under control, and separate development feedback from final evidence.
On this page
The question for today
What you’ll understand
- Distinguish a sampling frame from a deployment population.
- Explain entity, temporal, and transformation leakage.
- Preserve development and confirmatory test roles with known inclusion assumptions.
A team randomly divides individual support messages into train and test files. Several messages in both files belong to the same conversation, and a retrieved summary was written after the event being predicted. The files have different row IDs but do not provide the intended independent future test. Construction must preserve the relevant entity and time boundaries as well as the population sampling plan. Begin with the deployment question, then document which records can enter each split and what information would have existed when each evaluated decision was made.
Describe the frame and its selection process
The sampling frame is the inventory from which cases can actually be selected. A log export may omit unauthenticated users, failed requests, certain languages, or deleted sessions. Random selection from that export is random relative to the frame, not automatically representative of all deployment traffic. Record eligibility, collection dates, inclusion probabilities where known, and the exclusions. Separate a probability sample intended for population estimation from a curated challenge suite intended to expose mechanisms. Both can be useful, but their raw scores support different generalization claims.
For a finite frame with known inclusion probabilities, design-based weighting can estimate the mean of fixed outcomes under that sampling design. Every target item needs positive inclusion probability, and the estimator and variance method must match the design. A convenience sample with unknown selection is not repaired by assigning arbitrary weights afterward. In a stratified design, retain stratum sizes and selection counts; in a clustered design, retain cluster IDs. The information discarded during dataset assembly often determines which uncertainty calculations are defensible later.
Split at the boundary that prevents the relevant leakage
If the intended claim concerns unseen conversations, keep all messages and derived artifacts from one conversation together. For new repositories, splitting individual functions can leak shared code, templates, or near duplicates across files. Fit preprocessing, retrieval indexes, example selection, and calibration only with the information permitted by the protocol. A future-oriented test also needs point-in-time feature and source cutoffs. A random row split cannot prevent a later document or label from revealing an answer that was unavailable when the target decision would have occurred.
Train, development, and final-test roles should be stated separately. Development examples may guide prompt or threshold choices, while the confirmatory set is reserved for the declared final comparison. Repeatedly examining final scores to choose a model makes that final set part of selection, even if no gradient update reads its labels. Dwork and colleagues analyze this adaptive reuse problem; their specialized mechanisms do not mean an ordinary repeatedly queried holdout remains automatically valid. Benchmark-specific splits and shot conventions also matter: preserve the original MMLU protocol when claiming that benchmark result.
Freeze construction rules and retain an exclusion trail
Specify deduplication, normalization, answer extraction, filtering, and scoreable-outcome rules before reading the confirmatory results. Keep counts and reasons when records are excluded, including records that fail generation or parsing. A changed filter can change the task population rather than improve the model. Version the inclusion query and source snapshot so another evaluator can reconstruct the denominator. A fresh test can reduce feedback leakage but still miss the deployment population; sampling validity, access control, and temporal realism are distinct requirements that need their own evidence.
The probability lab illustrates only a simple coverage calculation for independent draws. Reset, set both p=0.1 and n=10, predict the chance of zero designated-category records, then inspect the zero-success bar. It is 0.9^10≈0.34868. The model neither builds a dataset nor detects duplicates. It shows that a ten-item random sample can miss a ten-percent category, even under an ideal known frame. Actual test construction should therefore retain category counts and design evidence instead of treating random selection as a guarantee of comprehensive coverage.
Work it through
Known inclusion probabilities change the finite-frame estimate
A fictional frame contains 1000 requests: 900 routine and 100 specialist requests. Sample 90 routine and 50 specialist records uniformly without replacement within each stratum. Their observed success totals are 72 and 30. Outcomes are fixed for this design-based calculation.
The inclusion probabilities are 90/900=0.1 for routine requests and 50/100=0.5 for specialist requests. Both strata have positive known inclusion probabilities.
Expand observed successes by inverse inclusion probability: 72/0.1+30/0.5=720+60=780 estimated successes in the frame.
Divide by the known frame size 1000 to obtain 0.78. The unweighted sample mean 102/140≈0.72857 answers the oversampled sample mixture instead.
The design-based frame-mean estimate is 78%. A variance estimate still needs the stratified sampling design and finite-population considerations; the weighting arithmetic does not cover populations outside the frame.
The living notebook
Explore the model
Interactive lab · probability
A probability sample can miss a category
Reset, set both p=0.1 and n=10, predict, then inspect. The exact zero-success bar is 0.9^10≈0.34868 for ten independent draws. The lab has no sampling frame, finite-population selection, entity grouping, or leakage detector; playback only highlights outcomes.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. 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 forRandom selection has quantified coverage limits under stated assumptions. Group boundaries, source cutoffs, and actual slice support require separate construction checks.
Pause & reason
Check your understanding
Your turn
Try it yourself
A finite frame has 800 routine and 200 specialist requests. Sample 80 and 100 respectively, observing 64 and 60 successes. Compute the inverse-inclusion estimate of the frame success mean.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use π=0.1 and π=0.5, then divide expanded successes by 1000.
Compare with the solution
Expanded successes are 64/0.1+60/0.5=640+120=760, giving 0.76. The raw sample fraction 124/180≈0.68889 uses the oversampled mixture. Neither establishes validity if the selection probabilities or fixed-outcome assumptions were recorded incorrectly.
Keep the idea
Take it with you
- A sampling frame and its exclusions bound the population claim.
- Preserve grouping, temporal availability, and development/test roles.
- Known design weights support a stated estimator; unknown selection and adaptive reuse need separate treatment.
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.