Practice in Lab: Join only features available at prediction time →
Join only features available at prediction time
A historical event timestamp does not prove that its feature value was available to a prediction system then. Late ingestion and backfilled corrections can leak future knowledge into training. A point-in-time join must consider publication or availability time as well as event time.
This exercise chooses the latest eligible event per entity for each query. Both timestamps must be no later than the prediction timestamp. Ties are resolved by availability time. Missing history returns None instead of borrowing a future observation. Real pipelines must also document revisions and retention of historical feature versions.
events=[(1,2,"known"),(2,8,"late")]
prediction_time=4
print([v for event,available,v in events if event<=prediction_time and available<=prediction_time])Review the design
Point-in-time correctness is a data-lineage property, not just a split choice. Backfills should preserve availability history so offline experiments can reconstruct what the online system actually knew.
Your task
Implement asof_values(events,queries). Events are (entity,event_time,available_time,value); queries are (entity,time). Return latest eligible value ordered by (event_time,available_time), or None. No mutation; ties with identical timestamp pairs are outside this contract.
The explanation opens here once every check passes.