What Could We Know at Prediction Time?
A model can appear remarkably accurate when a feature contains information that arrives after the decision. We need to reconstruct what was actually available when each prediction would have been made.
13 sections · 4 questions · 2 coding challenges
The arrow keys move between sections too.
When a Successful Evaluation Used Unavailable Information
BOTIE
Kaufman and colleagues examined leakage as information about a target that is not legitimately available to the prediction process. Our invented repair records make the timing issue explicit. Other forms include fitting preprocessing on test data or placing copies of an observation on both sides of a split.
Can We Predict a Repair Using the Completed Repair Report?
Botie wants to predict at noon whether a greenhouse sensor will need repair later that day. The data export includes a morning reading, a noon reading, and a completed repair report entered that evening.
The evening report could make the prediction look easy. It may even state the answer. But it was not available at noon, so using it would test a different task from the one we intended to solve.
These availability times are invented to expose the prediction-time boundary.
Step 1 of 3
Fix the decision time
The task is to make the decision at noon. That time determines the boundary of available evidence.
- Prediction time
- 12:00
Step 2 of 3
Check when each field became available
Use availability time, not merely the date written inside a later report.
| Field | Became available | Known by 12:00? |
|---|---|---|
| Morning reading | 09:00 | Yes |
| Noon reading | 12:00 | Yes |
| Repair report | 18:00 | No |
Morning reading
- Became available
- 09:00
- Known by 12:00?
- Yes
Noon reading
- Became available
- 12:00
- Known by 12:00?
- Yes
Repair report
- Became available
- 18:00
- Known by 12:00?
- No
Step 3 of 3
Keep only the evidence available then
The boundary includes the noon reading under this exercise's convention. The evening report is excluded.
| Available by noon? | Availability mask |
|---|---|
| Morning (09:00) | 1 |
| Noon (12:00) | 1 |
| Repair report (18:00) | 0 |
Morning (09:00)
- Availability mask
- 1
Noon (12:00)
- Availability mask
- 1
Repair report (18:00)
- Availability mask
- 0
Availability time determines whether a feature is usable
The gate compares the cutoff with each availability time. Selection keeps only the measurements whose evidence was available then.
Which readings existed when the decision was made?
The export contains information that arrived at different times. Move the decision cutoff and check which measurements Botie could actually have used at that moment.
BOTIE
Measurements available by the cutoff
- 019
- 122
Follow the operations
1. Corresponding measurements
- 019
- 122
- 299
2. Prediction cutoff hour
12
3. Availability hours
- 09
- 112
- 218
4. Threshold gate
- 01
- 11
- 20
5. Select real entries
- 019
- 122
6. Result
- 019
- 122
Times are simplified whole hours. A real system also needs dates, time zones, ingestion delays, and update history.
1. Define the Decision Before Selecting Features
State what is predicted, for whom, and at what time. Without that definition, we cannot judge whether a feature was available legitimately.
Our task is a noon prediction of later repair need. A completed evening report fails the timing requirement even if it is stored in the same row as the morning measurements.
A column's name is not enough. Investigate how the value was created, updated, and joined into the table.
2. Compare Availability With the Cutoff
Each field has an availability time. Keep it only when that time is at or before the prediction cutoff. The workshop uses whole hours to make this boundary visible.
Prediction cutoff: 12
Availability times: [9, 12, 18]
Available by cutoff: [1, 1, 0]The timestamp of the underlying event can differ from the time the system learned about it. A report describing a morning event but uploaded in the evening still cannot be used at noon.
3. Keep Fitting Inside the Evaluation Boundary
Leakage does not require an obviously future-looking column. A mean, vocabulary, selected feature, or imputation reference learned using held-out observations has also crossed the evaluation boundary.
Split first according to the intended prediction setting. Fit preprocessing and the model on training data. Apply those fitted choices to validation or test data without relearning from the held-out group.
Pipelines help with the order of fitting operations. They cannot determine whether a raw field was available at the intended decision time. That requires knowledge of the data collection process.
4. Test the Procedure You Can Actually Run
A realistic evaluation replays the information constraints of deployment. Time order, delayed labels, related entities, and record updates may all matter. A random row split is not automatically wrong, but it answers the wrong question when it ignores the dependency we care about.
The workshop returns the eligible measurements in their original order. It does not decide whether those features are useful or ethically appropriate; it checks the stated timing boundary.
Removing leakage may lower the score. That is a better measurement of the intended task, not a reason to put the unavailable information back.
5. A Record Has an Event Time and an Availability Time
A repair may concern a noon failure but only be entered that evening. If Botie predicts at noon, the repair report is unavailable even when a retrospective export assigns it the failure's date. An event timestamp alone does not establish that a feature was usable.
For each input, record how it is obtained and when it becomes available. Reconstruct training rows from that point of view. A lag must account for reporting delay, not merely move a value to an earlier-looking column.
6. Ask Whether Changing Tomorrow Changes Today’s Input
A useful test is to alter future observations while leaving the available history fixed. A correctly constructed historical feature should stay unchanged. This does not prove the whole pipeline is clean, but it catches a direct violation of the information boundary.
Apply the same reasoning to preprocessing, category vocabularies and feature selection. If future rows influence a fitted reference, the leak can remain even when the final model sees only historical rows.
Perturb the unavailable suffix
The prediction is made at index three using the two preceding readings.
import numpy as np
def trailing_mean(y, origin):
return float(y[origin-2:origin].mean())
y = np.array([10., 12., 14., 16., 18.])
changed = y.copy()
changed[3:] = 999
print(trailing_mean(y, 3))
print(trailing_mean(changed, 3))13.0
13.0A centred rolling window would fail this check because it would include an unavailable reading.
Check yourself
Questions on Information Available at Prediction Time
Question 1 of 1
Does this feature respect the information boundary?
Use this setup.
At origin 3, indices 0,1,2 are available. Tomorrow begins at index 3. A feature is the mean of y[1:4].Check yourself
Questions on Parts 1 to 6
Question 1 of 3
A report entered at 18:00 was available for a 12:00 prediction just because it describes a morning event.
Try it with Botie
Build with Botie
Write and run Python