Hard Databricks-ML-Associate practice questions
Challenge — multi-step scenarios, trade-offs, and subtle distinctions. 8 hard questions available — no sign-up, always free.
A data scientist has created a feature table in Unity Catalog named prod.retail.customer_features with primary key customer_id. They build a FeatureLookup to join these features onto a labeled training DataFrame using FeatureEngineeringClient.create_training_set(). When they call training_set.load_df(), the resulting DataFrame contains null values for all feature columns even though the feature table is fully populated. What is the most likely cause?
A data scientist is building a training dataset using a Databricks Feature Store feature table that stores time-varying customer metrics (e.g., rolling 30-day spend) with a timestamp column. Each training label event also has its own event timestamp. When creating the training set with FeatureLookup, the scientist wants to ensure that each label row is joined only with feature values that were known at or before the label's event time, preventing data leakage from future feature updates. Which approach correctly achieves this?
A data scientist is using Hyperopt to tune a gradient boosting model. They want to search for the learning rate over a range from 0.001 to 0.1, and they know that this parameter's effect is multiplicative rather than additive—values like 0.001, 0.01, and 0.1 should each get comparable exploration. Which search space definition should they use for the learning rate?
A data scientist is tuning a Spark ML pipeline using CrossValidator with a 3-fold cross-validation and a parameter grid of 4 combinations. After fitting, they want to inspect the individual model trained for every fold and every parameter combination (not just the final best model refit on all data) to analyze fold-level variance. By default, what does the fitted CrossValidatorModel expose, and what must be changed to access every fold's model?
A data scientist is training a gradient-boosted tree classifier on a 500 GB dataset stored in a Delta table that does not fit in the memory of a single worker. They want to tune 6 continuous and integer hyperparameters efficiently, exploring the search space adaptively rather than exhaustively, while keeping all training distributed across the cluster. Which approach best fits these requirements?
A data engineer needs to score a 200-million-row Spark DataFrame using a registered scikit-learn model in Unity Catalog. Before prediction, each row must be enriched by calling a preprocessing function that depends on grouping records by 'store_id' to compute a rolling group-level statistic that the model expects as a feature. The engineer wants the enrichment and prediction to run in a single distributed pass. Which approach best satisfies these requirements?
A data engineer needs to score 500 million records in a nightly Spark batch job using an MLflow model registered in Unity Catalog. Each record must first be grouped by 'store_id' so that a store-specific normalization step (implemented as custom Python logic requiring the full group in memory) is applied before the model's predictions are generated. Which approach correctly handles the per-group preprocessing and inference in a distributed manner?
A data scientist is preparing a customer churn dataset that contains a high-cardinality categorical feature, 'zip_code' (over 30,000 unique values). They decide to use target (mean) encoding, replacing each zip code with the average churn rate observed for that zip code. To avoid inflating validation performance, which approach should they use when computing the encoding?