Databricks ML Associate Practice Question 2: Feature Lookup Batch Scoring
Databricks Certified Machine Learning Associate · Test 1 · question 2 of 10
A data scientist trained a churn model with FeatureEngineeringClient. The training DataFrame held customer_id and the label churned, and a FeatureLookup on the feature table ml.churn.customer_features (primary key customer_id) supplied 12 feature columns. The model was logged with fe.log_model(..., training_set=training_set).
A new batch of customers now needs scoring with fe.score_batch(model_uri=..., df=batch_df). Which columns must batch_df contain at a minimum?
Show answer and explanation
Answer:
When a model is logged with fe.log_model and a training_set, the model is packaged with its feature metadata. At inference time fe.score_batch uses that metadata to fetch the required features from the feature tables automatically, joining on the lookup key. batch_df therefore needs only the lookup key, customer_id. The DataFrame that comes back is batch_df with the feature columns and a prediction column added.
Option A mixes up training and scoring. The training DataFrame needs the lookup keys and the label; a scoring DataFrame needs no label, because the label is what is being predicted. Passing the feature columns yourself is also unnecessary.
Option B fails because without customer_id the client cannot join to ml.churn.customer_features. The lookup key is the whole mechanism.
Option C includes the label, which is only required by create_training_set. It is never needed for scoring and usually does not exist yet.
Reference: Use features to train models