# Free DMLA practice questions

> 10 free DMLA practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/databricks-machine-learning-associate/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/databricks-machine-learning-associate/

### Question 1 of 10

A newly registered model version, ml.prod.fraud version 7, has passed validation and should replace version 5 as the version used by production scoring jobs that load 'models:/ml.prod.fraud@champion'. What is the recommended action?

- A. Call client.set_registered_model_alias('ml.prod.fraud', 'champion', 7)
- B. Call client.transition_model_version_stage('ml.prod.fraud', 7, 'Production')
- C. Call client.delete_model_version('ml.prod.fraud', 5) so that only version 7 remains
- D. Call client.set_model_version_tag('ml.prod.fraud', '7', 'role', 'champion')

**Answer:** A

**Explanation:** Aliases are mutable pointers in the Unity Catalog registry; reassigning 'champion' to version 7 makes every consumer of models:/ml.prod.fraud@champion pick up the new version, and the alias moves away from version 5 automatically. Stage transitions belong to the legacy workspace registry, a tag is descriptive metadata that does not change URI resolution, and deleting version 5 is destructive and removes the rollback option.

### Question 2 of 10

A team serves a model in real time that was trained with features from Unity Catalog feature tables. Request latency must be in milliseconds, and the client only knows the customer_id. What must be in place?

- A. A nightly batch job that writes predictions so the endpoint simply returns the stored prediction
- B. A larger SQL warehouse attached to the endpoint so each request can query the offline Delta table
- C. A copy of the feature table embedded inside the model artifact so features ship with the version
- D. The feature table published to an online store so the endpoint can look up features by customer_id

**Answer:** D

**Explanation:** For automatic real-time feature lookup, the offline feature table is published to an online store, which provides millisecond key-value reads to the serving endpoint. Querying Delta through a warehouse per request is too slow, embedding a static copy of features in the artifact goes stale immediately, and precomputed predictions are a batch pattern that changes the design rather than enabling real-time lookup.

### Question 3 of 10

A team builds its models in a dev workspace and promotes them to production. Retraining the model takes three weeks on GPUs and is costly, and the production data is also available in dev. Which promotion approach is most suitable?

- A. Promote the notebook source only and ask the production team to rerun the training with their own settings
- B. Promote the training code and retrain the model from scratch in the production workspace after every release
- C. Promote the feature tables only, because production jobs rebuild the model automatically from feature lineage
- D. Promote the trained model artifact, for example by copying the validated version into the production catalog

**Answer:** D

**Explanation:** When training is expensive and hard to reproduce, deploying the model itself avoids paying for training again in each environment; in Unity Catalog this can be done by copying a validated version into the production catalog. Retraining from code in production repeats a three-week GPU job, handing over notebooks invites inconsistent results, and feature lineage does not rebuild models.

### Question 4 of 10

A training notebook builds a training set with FeatureEngineeringClient.create_training_set and logs the model with fe.log_model, passing that training set. What does this enable at scoring time?

- A. Model Serving endpoints read the offline Delta feature table directly for each request at prediction time
- B. The model can be scored with fe.score_batch only on the same cluster that ran the original training notebook
- C. The scoring job must rebuild the training set with create_training_set before every call to model.predict
- D. fe.score_batch can look up the required features by key, so the scoring DataFrame only needs the lookup keys

**Answer:** D

**Explanation:** Logging with fe.log_model packages the feature lookup metadata with the model, so score_batch joins the needed features from the feature tables and the input DataFrame only needs the keys. Scoring is not tied to the training cluster, rebuilding the training set is unnecessary, and real-time endpoints use an online store rather than scanning the offline Delta table on each request.

### Question 5 of 10

A Spark ML OneHotEncoder with default settings is applied to an index column that holds 4 categories. How many elements does each output vector have, and why?

- A. 4, because each category always gets its own slot in the output vector
- B. 3, because dropLast=True by default encodes the last category as all zeros
- C. 5, because one extra slot is reserved for unseen categories by default
- D. 1, because the encoder keeps only the category's numeric index in a vector

**Answer:** B

**Explanation:** OneHotEncoder defaults to dropLast=True, so 4 categories produce vectors of length 3 and the last category is all zeros, which avoids perfectly collinear columns. A length of 4 requires dropLast=False, the encoder outputs indicator positions rather than the raw index, and an extra slot for unseen values only appears with handleInvalid='keep', not by default.

### Question 6 of 10

A data scientist is preparing features for a gradient-boosted tree model, and one categorical feature, 'zip_code', has about 30,000 distinct values. Why is one-hot encoding a poor choice here?

- A. It removes the most frequent category, so the model loses information for most rows
- B. It creates a very wide, sparse feature set that trees split on poorly
- C. It is undefined for string columns, so Spark ML refuses to encode zip codes in any form
- D. It forces trees to treat zip codes as ordered numbers, which creates misleading splits

**Answer:** B

**Explanation:** With tens of thousands of levels, one-hot encoding yields an extremely wide and sparse representation, and tree models need many splits to use individual binary columns, so alternatives such as target or frequency encoding are preferred. Strings can be one-hot encoded after indexing, ordinal treatment is the problem of label encoding rather than one-hot, and dropping one level is a reference-category convention, not information loss.

### Question 7 of 10

A data scientist fits a StringIndexer and a StandardScaler on the full dataset and only then splits it into training and test sets. Test performance later turns out much worse in production. What is the main problem with this workflow?

- A. StandardScaler cannot be used before tree-based models, so the test results are invalid for every model type
- B. StringIndexer must always run after StandardScaler, because scaling changes the order of the category indices
- C. The split should have been done with randomSplit weights that sum to more than one to account for the scaling step
- D. Test-row statistics leaked into preprocessing; preprocessors should be fit on training data only

**Answer:** D

**Explanation:** Fitting preprocessors on all the data lets information from test rows influence the training features, giving optimistic test metrics; fitting a Pipeline on training data only and applying it to test data avoids this leakage. Stage order does not affect index assignment that way, randomSplit weights are normalized, and scaling is harmless though unnecessary for trees.

### Question 8 of 10

A team has a 30-minute budget to tune five hyperparameters, and only two of them strongly affect performance. Why is random search often better than grid search here?

- A. Random search always finds the global optimum, while grid search only finds local optima in space
- B. Random search needs no evaluation metric, so it skips the validation step and finishes faster
- C. Random search learns from earlier trials to focus on promising regions as the search progresses
- D. Random search tries more distinct values of the important parameters for the same number of trials

**Answer:** D

**Explanation:** With a fixed budget, a grid spends many trials varying unimportant parameters while repeating the same few values of important ones; random sampling gives more distinct values on every dimension. Random search does not guarantee a global optimum, it does not adapt to past results (that is Bayesian search), and it still evaluates every trial on validation data.

### Question 9 of 10

A regression model predicts log(price) because the price target was log-transformed during training. The business wants RMSE reported in dollars. What must the data scientist do before calculating RMSE?

- A. Compute RMSE on the log-scale values and multiply the result by the mean price to convert it into dollars
- B. Take the log of the original dollar prices a second time so that both columns share the same double-log scale
- C. Report R-squared instead, because RMSE cannot be calculated for any model that was trained on a log target
- D. Exponentiate the log-scale predictions back to dollars and compute RMSE against the original prices

**Answer:** D

**Explanation:** Predictions from a log-target model are in log units, so they must be exponentiated back to dollars and compared with dollar prices before RMSE is meaningful to the business. Scaling a log-space RMSE by the mean price is not a valid conversion, double-logging moves further from dollars, and RMSE can be calculated once the values are back on the original scale.

### Question 10 of 10

A custom model class subclasses mlflow.pyfunc.PythonModel and needs a tokenizer file at prediction time. How should the file be made available to the served model?

- A. Pass it in the artifacts dict when logging and load it in load_context from context.artifacts
- B. Upload it to the endpoint's container after deployment with a shell command
- C. Store the tokenizer bytes as a model version tag, then read it from the registry
- D. Hard-code the notebook's local driver file path to the tokenizer inside the predict method of the class

**Answer:** A

**Explanation:** Artifacts passed when logging a pyfunc model are packaged with the model, and load_context receives their local paths via context.artifacts, so the served model can load them on startup. Local notebook paths do not exist in the serving container, tags are not meant for binary data, and serving containers are not modified manually after deployment.

Ready for a timed run? Take the free 15-question DMLA mini exam: https://devopscodelab.com/app/exams/databricks-machine-learning-associate/mini/

DevOpsCode Lab is not affiliated with Databricks. DMLA and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
