Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Machine Learning Associate

Training and scoring with feature tables

Databricks Machine Learning Associate · Lesson 3 of 19 · 16:40

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.

In this lesson

Prepare for the Databricks Certified Machine Learning Associate exam. In this lesson: building a training set with feature lookups, point-in-time lookups for time series features, logging a model with its features, batch scoring that looks features up automatically, and online stores for real-time lookups. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Two joins that disagree

Juniper Rides now keeps its rider features in Unity Catalog, but each training notebook still joins them by hand, and the weekly scoring job joins them again, with slightly different code. When a feature definition changed, training and scoring disagreed for days. This lesson covers how to train a model with features from feature tables, how to score it, and the difference between offline and online feature tables.

Building a training set

Training starts from a DataFrame of labels, like one row per rider with the rider ID, a date, and whether the rider renewed the monthly pass. For each feature table, a FeatureLookup names the table, the features to use, and the lookup key, the column of the label DataFrame that matches the table's primary key. create_training_set joins the lookups to the label DataFrame, with the name of the label column, and exclude_columns drops columns, like keys, that the model should not see. With a time series key, a timestamp lookup key makes the join point in time correct, so each row only gets feature values from before its own date. And load_df returns the joined DataFrame that the model trains on.

Logging with features

Train the model on the DataFrame from load_df, then log it with the log_model method of the FeatureEngineeringClient, passing the model, its flavor, and the training set. The model is then packaged with its feature metadata: it knows which features it needs, from which tables, and with which keys. Passing a registered model name also registers it in Unity Catalog, and the lineage links the model to its feature tables. A model logged with the plain MLflow function, without the training set, does not carry this metadata, so it cannot look up its own features.

Batch scoring

To score in batch, call score_batch with the model's URI and a DataFrame that holds only the keys, like rider IDs. score_batch reads the feature metadata, looks up the feature values in the feature tables, applies the model, and returns the DataFrame with the features and a prediction column. The caller joins no features, so training and scoring always use the same feature definitions. With a time series feature table, a timestamp column in the DataFrame makes score_batch look up the values as of that time.

Offline or online

Feature tables in Unity Catalog form the offline store: Delta tables used to discover features, train models, and score in batch. Real time applications need features in milliseconds, which the Databricks Online Feature Store provides: powered by Lakebase, it serves feature values with low latency at high scale. You create an online store, then publish_table syncs a feature table to it, and only the latest values for each key are kept online. The default, triggered mode syncs changes incrementally, when you run it or on a schedule; continuous mode streams changes as they are written; and snapshot mode copies the whole table once. The triggered and continuous modes need the change data feed on the offline table. A model serving endpoint then looks up the features it needs from the online store automatically, so a request can carry only the keys.

Recap

Let's recap. A FeatureLookup names a table, its features, and the lookup key, and create_training_set joins the lookups to the labels, with exclude_columns for the keys. A timestamp lookup key on a time series table keeps the join point in time correct. Logging with the client's log_model and the training set packages the feature metadata with the model. score_batch then takes only the keys, looks up the features, and adds a prediction column. And the offline store serves training and batch, while publish_table syncs the latest values to the online store, for low latency serving.

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.

  1. A label DataFrame has a rider ID, a signup city, and the label; the feature table’s primary key is the rider ID. The model needs two features from it, but must not train on the rider ID. Which settings fit?

    • lookup_key set to the signup city column
    • feature_names that include the rider ID
    • lookup_key rider ID, exclude_columns rider ID
    • label set to the rider ID column
    Show the answer

    lookup_key rider ID, exclude_columns rider ID

    The rider ID is the lookup key that matches the primary key, and exclude_columns keeps it out of the training data. “lookup_key set to the signup city column” would join on the city, which is not the key of the table. “feature_names that include the rider ID” would treat the key as a feature, which is what the model must avoid. And “label set to the rider ID column” would make the model predict the rider ID.

  2. A renewal model was logged with the client’s log_model and its training set. A weekly job has a DataFrame with only the rider IDs of active riders. What should it call to get predictions?

    • create_training_set on the rider IDs
    • score_batch with the model URI and the IDs
    • read_table, a manual join, then predict
    • publish_table to an online store
    Show the answer

    score_batch with the model URI and the IDs

    Score_batch looks up the features from the rider IDs, using the metadata packaged with the model, and adds the predictions. “create_training_set on the rider IDs” builds training data, and needs a label, so it does not score anything. “read_table, a manual join, then predict” would join the features by hand, which the packaged metadata makes unnecessary, and which can drift from training. And “publish_table to an online store” would sync features for real time serving, without scoring.

  3. The app shows each rider a personal unlock offer, and must get the rider’s features within a few milliseconds when the app opens. The features are in a Delta feature table. What should the team set up?

    • Publish the table to an online feature store
    • Run score_batch on every rider each hour
    • Add liquid clustering on the rider ID column
    • Cache the table on an all-purpose cluster
    Show the answer

    Publish the table to an online feature store

    An online store serves the latest feature values with low latency, and a serving endpoint can look them up automatically. “Run score_batch on every rider each hour” would score every rider each hour, and the offer would use values up to an hour old. “Add liquid clustering on the rider ID column” would speed up queries on the Delta table, but not to a few milliseconds per request. And “Cache the table on an all-purpose cluster” would cache data on a cluster that the app cannot query.