A workshop wants to know, at the close of each week, how many plain repair kits it will pack in the next two weeks. A retrospective notebook has twelve weeks of dated inputs, and a chart appears to show a good forecast. The first question is not which model made the chart. It is whether the notebook could have issued each prediction at the time printed beside it. A later final total can properly tell the notebook what happened. It cannot properly be part of what the notebook already knew before making the prediction.

A chronological division helps recreate that sequence. Training belongs before testing, and a gap can keep the last selected training row far enough back that its outcome is available by the evaluation cutoff. Yet chronological ordering and a gap do not by themselves solve all information problems. An input can still contain a later correction or a calculation looking forward. A target can still need more time to become final than its date suggests. The useful audit follows at least two clocks: the time an input becomes usable and the time an outcome becomes known.
All weeks, workshop records and counts here are fictional. The chart describes assigned prediction-origin rows, not actual forecast findings. The software documentation is cited for its design and conventions, while the toy uses a single manually described split. There is no claim that two weeks is the right gap for another dataset.
Put the prediction origin on the calendar
The prediction origin is when a forecast is meant to be issued. For this example it is after the close of each weekly input collection. The outcome is the total packed in the next two whole numbered weeks, not including the origin week. For origin week six the target uses the pack counts in weeks seven and eight. For origin week nine it uses weeks ten and eleven. These rules define the two-week outcome horizon. The time printed in the origin column is not the time of every observation contributing to its target.
Set a training cutoff after the week-eight totals are available and before the first test prediction is made. Assume that all training targets through week six are finalized by that cutoff. Also assume the week-nine prediction is made after the close of week nine using only inputs available by that origin, without changing the already fitted model. Under those assumptions the last included training target reaches through week eight and does not extend into the test origins or their outcomes. The gap rows are not selected as prediction origins for fitting or scoring in the displayed split.
Each choice matters. If the forecast were issued before the close of the origin week, that week's final work count might not be an eligible input. If the week-eight target data arrive late, it might not be possible to include the week-six origin in a fit fixed at the chosen cutoff. If the forecast were instead for the current week plus the next, the outcome interval would be different even though someone could still describe it informally as “two weeks.” Precise timing comes from defining which observations belong to each row, not from the name of the task.
A label can also have an availability time later than the last day it measures. Perhaps the workshop records packing immediately but waits for a fixed reconciliation process before treating counts as final. The last date of a target window and the date when the target becomes available for training are then different. A split with the nominal right number of empty weeks can still be invalid if the preserved training labels could not have been used at the cutoff. Separating the outcome interval from the reporting delay makes such problems easier to discover.
An analogous distinction applies to historical inputs. A value may refer to week five and still have been published or revised later. The row's reference date does not guarantee that the final stored value was visible when a week-five forecast would have been issued. An evaluator may need a historical snapshot, a versioned source or a clear reconstruction of what was available then. Using final values can be acceptable for a different retrospective question, but it is not the same evaluation as a simulation of a live forecast from then-known inputs.
Weeks assigned to one chronological split
The chart and table count invented prediction-origin rows in the twelve-week assignment. They do not show training sample quality, completed outcomes, forecast errors, or an official target. Each block represents one week on a regular calendar grid with one candidate origin per week.
Training ██████ 6 Gap ██ 2 Test ████ 4
| Use of candidate origin rows | Count (weeks) |
|---|---|
| Training | 6 |
| Gap | 2 |
| Test | 4 |
The training origins are weeks one through six; weeks seven and eight are excluded as origins; test origins are weeks nine through twelve. Six plus two plus four equals twelve. The same calendar week can nevertheless be involved in more than one way. In particular, raw pack counts from weeks seven and eight contribute to the training target for origin six. They are not training-origin rows of their own. A gap in origin rows is not an instruction to erase every raw observation dated in the gap.
The test-origin count and the number of scores available at a calendar cutoff are also different. Origin nine needs weeks ten and eleven; origin ten needs eleven and twelve; origin eleven needs twelve and thirteen; origin twelve needs thirteen and fourteen. Thus four planned test origins require follow-up through week fourteen, as well as time to finalize the last target. If the raw archive really stops at week twelve, at most the first two of those four outcomes have completed their calendar windows. The chart does not invent observations beyond its assignment grid, and the last two scores should remain pending rather than appear as zero.
This distinction is a useful reason to mark both the scheduled analysis and its reporting coverage. A test may properly schedule a prediction for a date whose outcome is not yet known. Prediction and evaluation happen at different moments. A retrospective notebook can wait until the needed later counts have arrived, then evaluate without changing the original predicted values. A provisional report can clearly describe what remains unscored. Neither approach requires redefining the test set in hindsight as only the weeks that happened to finish early.
What the separator protects and what it leaves alone
A common mistake is to split just before week nine but include origins seven and eight in training. Origin seven's target reaches into week nine. Origin eight's target reaches into weeks nine and ten. If the model is frozen just before the first test origin, these labels incorporate information after that freeze. The split looks chronological because training-origin dates come first. The actual target information breaches the cutoff. Removing those origins for this particular demonstration creates room for the training outcomes to complete before fitting.
The opposite mistake is to say no data from weeks seven and eight can inform anything. A weight, count, or other historical input from that interval may genuinely be available to someone forecasting in week nine. The completed training target for origin six explicitly uses those weeks. What is excluded is using origins seven and eight as examples on either side of this particular fit-and-test boundary. A role assigned to a row does not determine every role of every source measurement touched by that row.
These rules are easy to confuse when all values have been flattened into a single wide table. Each row may appear to carry a single date, while each field was assembled from an interval. An input computed over the preceding four known weeks may end at the prediction origin. A label starting one week later and ending two weeks later may be deliberately forward-looking. A target finalized after a later reconciliation has a third availability date. The table is more auditable if the construction of each field preserves those timestamps or their derivation.
There are at least two separate questions an evaluator can state as tests. First, were all inputs to a prediction available at its origin? Second, were the target labels used to fit the model available when the fit was supposed to happen? The gap mainly illustrates the second. It can help separate certain windows when designed for that purpose, but it cannot cleanse a feature that was computed using future measurements from the same row. Adding a larger gap without fixing that feature would not simulate a live forecast.
Imagine a row labeled week six carrying a centered moving average that uses both week five and week seven. That value would not be usable as a week-six input at the stipulated origin. It does not become legitimate because origin six is well before the test. The training process would learn a relationship using a feature definition that could not be reproduced prospectively. Changing to a trailing summary or making a different prediction origin may address the issue. Merely deleting the next two training origins would leave the improper feature intact.
The software gap counts samples, not mind reading
The scikit-learn TimeSeriesSplit reference defines its gap parameter as the number of samples excluded from the end of each training set before the test set. It does not inspect the analyst's target creation rules, data publication timings, or meaning of a week. The scikit-learn cross-validation guide explains ordered evaluation for time series and the importance of comparable fold durations. The figure here uses one manual split to explain these ideas; it is not a claim that the cross-validator runs a single split or that its defaults generate these numbers.
In the toy there is one origin per week on a regular grid, so removing two adjacent origins spans those two calendar weeks. If rows are irregular, two samples may span a different amount of elapsed time. If records arrive more often during one season, the same sample-count gap can be short in one part of a timeline and long in another. Map the requested separation to real coverage before relying on a parameter. The software faithfully excludes indices; it cannot declare those indices a meaningful duration without context.
Rows can also contain multiple observations per origin. Suppose two workshop lines each supply a row for the same week. Excluding the last two rows might then leave a one-week boundary or even split an origin across training and test. If the deployment task forecasts both lines for future weeks, define cutoffs by calendar or another relevant grouping instead of treating two rows as two weeks. If testing entirely new lines is also important, group holdouts may be a separate question. One chronological split does not establish transfer to units that were not studied.
Do not sort the training and test samples independently and assume that means the split was chronological. A shuffled assignment stays shuffled even if each subset is shown in order afterward. Verify the complete ordered set of origins and their positions on both sides of a shared cutoff. Also verify that parsing the dates did not mistake strings for chronological order or put two records with equal keys in arbitrary order. The unit being held out is part of the evaluation design, not a formatting detail.
A useful hand check can still be performed before choosing a library. Write the last permissible training cutoff, then write the end and likely availability of the final label for each candidate near the boundary. Write the first test origin and the latest legitimate input time for that origin. Verify that the first list is entirely available for the planned fit and that the second list does not incorporate later knowledge. This is the substantive rule the indices are supposed to implement. It remains valuable if the project later changes tool or workflow.
Random assignment answers a different question
A random train-test split can be appropriate when the goal concerns exchangeable examples under a design that supports that assumption. It is not a substitute for a rehearsal of forecasting forward in time. In the workshop case it can put a later production week into training and an earlier week into test. The pipeline would see patterns, updates, or labels that were not available when the earlier prediction would have been issued. Merely including a date as a feature does not make that prediction prospective.
Time-adjacent rows can also resemble each other unusually strongly. With a two-week target, neighboring origins share some outcome weeks by construction. If one is assigned to training and one to test without attention to their windows, common events can affect both target values. That can make an apparent validation less informative about future use. Not all dependence causes direct leakage, but it changes what a test can be expected to tell someone. The ordered design is valuable because it names the direction of generalization the evaluation is trying to imitate.
A chronological split does not establish that all test errors are independent. The example's week-ten and week-eleven targets share the week-twelve total. An unusual count that week can affect both errors. A metric averaged over the four issued forecasts still describes the declared origin-weighted scoring convention. It should not automatically be described as four independent pieces of evidence about forecast quality. If quantifying uncertainty or comparing models, the temporal dependence may need explicit treatment and much more data than a classroom grid supplies.
Dependence on prior values can also be legitimate. A live forecast may deliberately use the past week's count, and the row for one forecast can reasonably use information that contributed to an earlier forecast. This is not a failure of the split simply because the feature windows touch. The crucial distinction is between information available at the relevant origin and information only known later. The test should reflect how the tool actually uses history, rather than demanding that past context vanish at every forecast boundary.
If random evaluation is used for another aim, label that aim. For example, a method might be checked for how well it reconstructs missing rows when other observations from the same period are already known. That is not the workshop's future forecast. Two evaluation protocols can yield different scores without either implementation being broken because they answer different questions. Comparing their numbers without noting the difference in information allowed at prediction time is usually the bigger error.
Put availability on each path that reaches the fitted model
Preprocessing can use future information even when the final model receives the correct rows. An imputation statistic estimated from the whole archive can carry features of the test period back into training. A scaling factor computed using both subsets can do the same. A filter that chose useful predictors by looking at test labels affects the training procedure even if no test row appears in the final fit command. The scikit-learn guidance on avoiding data leakage explains why transformations learned from data belong inside the training process for each appropriate split.
Distinguish computing a transformation on a particular row from learning its parameters. Applying a scaler fitted on training rows to a future input is the normal use of that fitted scaler. Updating its mean from future test data before scoring would evaluate a different procedure. A rolling input derived solely from values available by the row's origin is another legitimate role. A transformation computed once from the entire timeline can be easier to write but deserves scrutiny even if it has a familiar name like standardize or fill.
Prediction-time input availability can differ from availability when the model was trained. A fixed model fitted at the end of week eight can accept new week-nine inputs after they are observed if the intended deployment would do so. That does not mean the model was retroactively trained on week-nine rows. Confusing the time of the fit with the time of feature extraction may lead someone to reject all later inputs, even those required by the stated forecast. Document what is frozen and what legitimately changes at each new origin.
Data revisions create a similar path into the evaluation. Suppose week-four input was preliminarily reported as one value and corrected once week eight's reconciliation was complete. A model trained at week eight may have access to the correction for some historical purposes. A simulated forecast at origin four would not. The proper treatment depends on the development and backtesting policy: does training use final historical features, or snapshots reconstructed as of each prediction origin to mimic deployment? Do not let a notebook silently make these choices. At a minimum the scoring inputs for simulated forecasts must honor the information available at the dates they claim to represent.
It is also useful to distinguish a data dependency from a human one. If the staff have already looked at the held-out forecast errors and used them to select a better gap, change features, or tune a threshold, the data have influenced development. Rerunning the last fit can still give a useful exploration, but the reported score no longer plays the role of an untouched final evaluation. A separate development timeline and final holdout can preserve that role. The gap alone does not protect against feedback from the people choosing the model.
Compute the smallest suitable separation by definition, not by copying the chart
The two gap weeks in the demonstration follow from three stipulations: the label starts after the origin, includes the next two weeks, and is finalized by the end of that window in time for the specified fit. Those conditions let the origin-six label be known by the cutoff, while the later candidate training labels would extend beyond it. If finalization takes longer or the cutoff moves earlier, the last admissible origin could be earlier. If the horizon or fit schedule is different, the exact boundary changes again.
Sometimes another separation is useful for a different reason. A project may wish to reduce extreme similarity between nearby training and test windows or to report robustness to an operational delay before scoring starts. A larger gap can make that evaluation more realistic for such a task. It also uses less candidate data and can change the conditions under which the test is run. There is no reason to maximize separation automatically. State the purpose and compare the selected boundary to the intended deployment calendar.
The general cutoff check can be framed without a fixed sample-count assumption. For every candidate training row, identify when the required training outcome and any information used to construct that row are available to the fit. Include it only if that timing satisfies the design. Separately, keep each test input to information available by its prediction origin. Some rows may be excluded for reasons not captured by a contiguous gap, such as a delayed publication for one region. An index-based separator is effective only when it matches the substantive eligibility rules.
Decide whether the model is fixed or allowed to update
The worked chart describes one fit before the test period. A different operational design may update after every origin using all newly matured outcomes then available. That evaluation can also be chronological, but it must replay the update process. A later test prediction may legitimately learn from outcomes that have become available since an earlier prediction, provided the protocol was defined and the chronology is enforced. In a first fixed-holdout comparison, doing so would violate the specified design. The distinction is not a universal ban on using data with test-era dates; it is a question about what experiment the score represents.
A rolling sequence can have several fits and several cutoffs. At each one, preserve the origins scored, the outcomes known at fitting, the inputs allowed, and the policy for learning any preprocessing. A fixed-window fit and an expanding fit use different portions of available history. That difference can matter if conditions change or old data represent another regime. The cross-validation guide describes common ordered schemes, but a report should name the scheme actually implemented instead of calling every series of fits the same design.
More test folds can provide evidence from varied conditions, yet multiple folds do not create independence if their labels overlap or their fits share much of the same data. For a simple report it may be enough to show per-fold performance and variation alongside an aggregate, with a description of what those folds share. Do not let an aggregate hide that some folds saw longer horizons, different reporting delays or different proportions of eligible origins. Comparable units and time coverage are needed before treating metric differences as informative.
When evaluating a model that actually retrains in production, an event ledger can make the protocol credible. Each fit has its own timestamp, data snapshot or query cutoff, configuration, and output identifier. Each prediction has an origin, the fitted model identifier and records of which input versions it used. Each score has a target definition and an availability check for the final outcome. These links distinguish a forecast made once from a series that was overwritten after later observations arrived. A gap in a final chart cannot reconstruct those histories if they were never saved.
Take a score only after stating what was scored
The six training origins and four test origins in the chart are not a recommended sample size. This example does not fit a model or produce a metric. In a real evaluation the display might report four forecasts were issued but only two had mature targets by the reporting cutoff. If a metric uses the two completed cases, its denominator and status should be named. Do not count unresolved outcomes as zero demand, as exact forecasts, or as missed forecasts without a separate definition requiring that classification.
This distinction matters when comparing two systems. If one issued predictions at all four origins and another skipped weeks with unavailable inputs, comparing scores on each available set may compare different calendar conditions. A report can name the common evaluation set and separately describe missing predictions. If ability to issue a timely prediction is itself important, give it an explicit metric. Keeping the coverage result distinct from numerical forecast error helps readers see which system had what opportunity to be scored.
A baseline can also have information constraints. For instance, a naive forecast might use only the most recent finalized total. It would not be a fair comparison to construct the baseline using more recent preliminary counts unavailable to it, or to compute its reference average using later outcomes. Put the same chronology checks around the benchmark and the more complex model. Improving a score against a baseline that knew too little or too much does not establish the gain a deployment would see.
Scoring definitions deserve similar alignment. A forecast of the sum over the next two weeks should be scored against that sum, not the total for a single one of those weeks. A forecast of planned work should not be compared with completed work unless that outcome was intentionally the target. The discipline of naming the horizon can expose this mismatch even when there is no leakage. Good timing is a necessary condition for a meaningful evaluation, not a substitute for defining what counts as a correct prediction.
A date label can hide a late correction
A common failure begins with a perfectly valid historical date on the source table. Suppose a record says it describes week five. Its first estimate was present at the close of week five, a revised value became available during week six, and a final value two weeks later. The column that reports which week the value describes may remain unchanged in all three versions. An automatic join on that column alone has no rule for which version it may use. Unless the version is recorded, the joined row can look chronologically correct even when it represents the future.
Keep at least an event or reference date and a separate availability date for a source where this distinction matters. Then, for a simulated prediction, select the appropriate available version as of its origin under the declared policy. For a training fit, likewise use target values that would have been available for fitting. A complete versioned dataset is helpful but not always recoverable. If a project has only final releases, document the limitation and say whether the evaluation is conditional on those final values. A gap describes an exclusion rule; it is not a time machine capable of retrieving past values.
The same issue applies to supposedly static metadata. A workshop may change the categorization of a type of repair kit after a review and amend earlier entries to match the new vocabulary. Reconstructing past input distributions with the new categories may be legitimate for one historical analysis. It is not automatically legitimate for a comparison whose purpose is to predict with the original workflow. State whether the feature would be available in the same form when the tool issues its future predictions. Be especially careful when evaluation time spans a version change or revised definition of the outcome.
A timestamp is evidence only as strong as its definition. Ingestion time in an analysis database may tell when the analyst obtained a copy, not when the original operator could see the measurement. For some systems the distinction is unimportant; for a forecast issued after a narrow weekly cutoff, it can determine eligibility. Document the intended clock and, where necessary, use source publication or usable-version timestamps rather than assuming an upload field has the same meaning.
Add rows to the calendar without adding nonexistent observations
A regular forecast schedule can contain an origin even when no usable feature data arrive. It is reasonable to maintain the weekly grid and record why a prediction could not be issued. That is different from filling the missing observation with zero and then trusting the model to handle it. The row may stay eligible under the chronological design but unavailable under the operational inputs. A report can count scheduled, issued and scored predictions separately, making it easier to see where the process actually broke down.
Conversely, a file may hold many measurements in one reference week. Extracting a weekly aggregate can be appropriate, but write down when the aggregation could be finished. Suppose a shop counted activity from every workday and computes the weekly summary only after the last workday. An origin at the start of that same week cannot use the final aggregate. An origin after the relevant close might. The row count and the calendar location are identical in both representations; the allowed information is not.
When label windows overlap, teams sometimes split by the dates of the raw outcomes rather than the dates of the forecast origins. This can be useful as a check, but alone it does not identify the records the model receives. One raw total may be a target component for a past origin, an observation from a legitimate feature window for a later origin, and irrelevant to a third. The correct labels attach roles to relationships between records, not permanent identities to every date. An audit can follow a particular total through the paths that reuse it and check each path separately.
Two other examples help prevent overcounting. If one weekly prediction is overwritten with later versions, the last saved prediction is not automatically the one that would have been available to users. And if a notebook evaluates each subcomponent of a two-week target then counts both as distinct issued forecasts, it changes the evaluation unit. Keep original outputs when possible and specify whether a score is per issued origin or per component. The fictional bar count is per candidate origin, which is why it can remain twelve even when there are more observations and fewer valid scores.
Read the chart differently from an implementation recipe
A stakeholder looking only at the chart can legitimately say that this proposal uses six training weeks, two excluded origins and four planned test weeks. They cannot infer that these intervals are long enough for the underlying forecasting problem or that the gap reached the last possible outcome. Those facts come from the explicit target window and timing assumptions. If the chart is passed around by itself, the caption should keep the word origins and a brief note about the later outcome requirements.
An engineer may use the same display as a checklist for selecting records. They should implement the stated cutoff in terms of the actual dataset, not blindly use a row-count parameter. In a clean regular series the index and elapsed-time choices line up. With duplicated origins, missing weeks, time zones, or delayed releases they can separate. Test the actual selected rows around a boundary, and compare the resulting inclusion against a small manually drawn timeline. That test is more direct than evaluating whether the trained model gives an attractive score.
Finally, a reviewer can use the chart to ask which claims are not being made. Nothing in the counts establishes that the chosen features can predict packing demand well. Nothing measures variance in performance or performance under a new regime. And nothing evaluates the consequences of using a forecast to change the workshop schedule. Defining a clean temporal comparison protects the evidence for whatever evaluation follows. It does not turn an evaluation design into an empirical result.
Audit a boundary before trusting its label
A small example ledger can test the cutoff rules without trusting any model. A training row whose target ends and becomes available before the fit should be admissible if its features also pass their own checks. A nearby row with a target that ends later should be rejected. A test row with a centered input that includes an observation after its origin should be flagged regardless of how much separation preceded it. A row whose outcome is not yet complete can be retained as an issued test prediction and labeled unscored. These are different statuses with different reasons.
When a chart is exported to another report, include enough context for another person to run those checks. Name the origins for training, gap and test and give the label horizon. Document the fitting cutoff, whether the model was fixed and whether any labels were delayed. If multiple series or a grouped split is used, specify what one row means. A short visual caption cannot carry the full provenance, but it can identify the objects it counts and point to the audit record. The chart becomes a map of the protocol rather than a certificate that it has been obeyed.
For a final cross-check, record both the earliest usable version and the version actually chosen for each field near the gap. An evaluator may discover that a preliminary input was available on time but the notebook substituted a later approved value during export. That is not simply an absent input; the error concerns which version was used. Marking the substitution explicitly helps distinguish a fixable data-assembly mistake from the more fundamental problem of a forecast that demanded information nobody had at its origin.
Return to the repair kits. The last included training origin is six because its outcome covers exactly weeks seven and eight, and the example assumes those counts are ready before fitting. It is only valid if its inputs were also eligible under their own clock. Test origins start at nine, and the last one requires a later observation window to be scored. The gap makes the relationship among those clocks visible. The checks on data availability, not the empty boxes alone, make the comparison a rehearsal of forecasting into the future.