How do you build a training set where every feature value is what was known at the moment of prediction?
Answer
Model answer, written in a candidate's voice
In short
- Key every feature by entity and valid-from event time, and join with as-of logic using feature_ts < label_ts, not <=.
- Use available-at/ingestion time as the real knowledge cutoff, not just event time, so late-arriving data is excluded.
- Persist snapshots or versioned feature tables so each historical prediction can be reconstructed exactly.
- Validate by recomputing features for past requests and comparing them to the values logged at prediction time.
In full
I would treat the training set as a point-in-time reconstruction, not a table of finalised values. Each feature row would carry an entity key, a valid-from event timestamp, and an available-at timestamp, and I would as-of join it to each label or prediction using feature_ts < label_ts, with the additional requirement that the value was actually available by the prediction moment. Event time alone is not enough, because a record can be dated in the past but only ingested later, so the cutoff must reflect what was known then. I would store snapshots or versioned feature tables so a past request can be rebuilt exactly as it was seen, including late-arriving or corrected data. Finally, I would test the pipeline by recomputing features for past requests and comparing them against the values logged at prediction time, and investigate any mismatch before trusting the training set.
What a strong answer covers
- Event-time keyed features with valid-from timestamps; as-of joins on feature_ts < label_ts.
- Account for ingestion latency (available-at time, not event time).
- Snapshot or versioned tables.
- Test by recomputing features for past requests and comparing with logged values.
Common mistakes
- joining on the latest snapshot
- using event time when the feature only landed hours later.