Point-in-time correct features
Databricks Machine Learning Professional · Lesson 10 of 22 · 1:11:01
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Databricks Certified Machine Learning Professional exam. In this lesson: data leakage, time series feature tables with a timestamp key, point-in-time lookups that join each label to the feature values known at that moment, and lookback windows. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Today's rating
Pebblecove's cancellation model uses the host's rating, which changes every week. In training, the team joined today's rating to bookings from last year, and the model looked excellent, then disappointed in production. The rating it learned from included reviews written after those bookings, and this lesson shows how point in time lookups prevent that.
Data leakage
Data leakage happens when training uses feature values that were not yet known when the label was recorded. A host's rating today includes reviews written after a booking from last year, and some of those reviews may even describe the cancellation itself. The model learns from the future, scores well offline, and then fails in production, where the future is never available. Point in time correctness fixes this: each training row gets the latest feature values known as of that row's timestamp, and nothing later.
Time series feature tables
A time series feature table has a primary key, like the host, plus a timestamp key, declared with timeseries_columns when you create it with the feature engineering client, or with the TIMESERIES keyword in SQL. Without that declaration, the timestamp gets no point in time logic, and the training set functions require every date or timestamp key to be declared. And this has nothing to do with Delta time travel, even though people sometimes call it time travel.
Point in time lookups
To build the training set, each FeatureLookup on a time series table names the lookup key, like the host, and the timestamp_lookup_key, the column of the label DataFrame that holds each row's time. create_training_set then performs an as of join: for each label, it takes the latest feature values recorded before its timestamp, or null when there are none. Every lookup on a time series table must give a timestamp_lookup_key. And a model logged with the feature engineering client keeps this metadata, so score_batch repeats the same point in time lookups for batch inference.
Lookback windows
Sometimes a value is too old to trust, like a rating from three years ago. The lookback_window argument of FeatureLookup, a timedelta, excludes values older than the window before each label's timestamp, and by default every value counts, whatever its age. The window applies to training and batch inference, while online inference always uses the latest value. When you publish a time series table to an online store, only the latest value of each key is kept, so online lookups are by key, not by time. And on large time series tables, Databricks recommends liquid clustering, to keep these joins fast.
Recap
Let's recap. Data leakage means training on feature values that were not known when the label was recorded. A time series feature table declares its timestamp key with timeseries_columns. Each FeatureLookup names a timestamp_lookup_key, and the as of join takes the latest value before each label. lookback_window ignores values that are too old, in training and batch inference. And online stores keep only the latest value of each key.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
A label was recorded at 9:10. The feature table holds rating values at 8:00, 9:00, and 9:30. Which value does a point-in-time lookup return?
- The 8:00 value
- The 9:30 value
- The 9:00 value
- The average of all three
Show the answer
The 9:00 value
The lookup returns the latest value recorded before the label's timestamp, which is the one from nine o'clock. “The 8:00 value” is older than the latest known value. “The 9:30 value” was recorded after the label, which is exactly the leakage to avoid. And “The average of all three” would mix in the future too.
Which argument of FeatureLookup names the column of the label DataFrame that holds each row's time?
- lookup_key
- timestamp_lookup_key
- timeseries_columns
- lookback_window
Show the answer
timestamp_lookup_key
Timestamp_lookup_key points to the time of each label, which the as of join compares with the feature timestamps. “lookup_key” would name the key to match, like the host. “timeseries_columns” would declare the timestamp key of the feature table, not of the labels. And “lookback_window” only limits how old a feature value can be.
Training rows should ignore any host rating older than 90 days before the booking. What should the team set?
- timestamp_lookup_key set to 90 days
- A Delta retention of 90 days on the table
- A filter on the label DataFrame
- lookback_window=timedelta(days=90) in the FeatureLookup
Show the answer
lookback_window=timedelta(days=90) in the FeatureLookup
Lookback_window excludes feature values older than the window, measured back from each label's timestamp. “timestamp_lookup_key set to 90 days” would name a column, not a duration. “A Delta retention of 90 days on the table” only removes old files of the table, and changes nothing in the join. And “A filter on the label DataFrame” would remove labels, not old feature values.