DMLP
Free DMLP practice questions
10 questions from our DMLP practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.
Question 1 of 10, Model Development
A team trains 2,000 per-region models with applyInPandas and wants each model logged to MLflow so it can be traced later. Which approach is MOST appropriate?
- AWrite each model to the driver's local disk from inside the function and later upload the whole directory as a single artifact with mlflow.log_artifacts()
- BInside the grouped function, start an MLflow run (optionally nested under a passed-in parent run ID), log the model with a region tag, and return the run ID Correct answer
- CEnable mlflow.autolog() on the driver only, because autologging propagates automatically into the pandas function that runs on each executor process
- DLog all 2,000 models from the driver after applyInPandas finishes by collecting the fitted model objects back with toPandas() and looping over them one by one
Answer and explanation: MLflow can be called from inside the pandas function running on workers when the experiment and credentials are provided, so each group logs its own run, and passing a parent run ID creates a navigable hierarchy; returning the run ID lets the team join results back. Collecting fitted models through toPandas() is not feasible for model objects at this scale. Autologging enabled on the driver does not configure the separate Python worker processes. Worker functions cannot write to the driver's local disk.
Question 2 of 10, Model Development
A fitted PipelineModel must score events arriving continuously in a Delta table, writing predictions to another Delta table with exactly-once guarantees. Which approach is MOST appropriate?
- AConvert the PipelineModel to scikit-learn format and score each micro-batch on the driver inside foreachBatch using toPandas()
- BRead the source with spark.readStream, call pipeline_model.transform() on the streaming DataFrame, and writeStream to Delta with a checkpoint location Correct answer
- CDeploy the PipelineModel to a Model Serving endpoint and have a scheduled job send every new row to it as an individual JSON REST request
- DRun pipeline_model.transform() in a Python while loop that reads the latest rows with spark.read every minute and appends the predictions
Answer and explanation: Spark ML transformers work on streaming DataFrames, so applying the fitted PipelineModel inside a Structured Streaming query with a checkpoint gives incremental, exactly-once delivery to Delta. A polling loop with batch reads has to track progress manually and risks duplicates or gaps. Spark ML models cannot simply be converted to scikit-learn, and toPandas() on each micro-batch bottlenecks the driver. Row-by-row REST calls add latency and cost for what is a high-throughput streaming scoring job.
Question 3 of 10, Model Development
A company has three inference needs for the same churn problem: a nightly scoring job over 300 million customers, a streaming job that scores app events within a few seconds, and a mobile app that needs predictions in under 50 ms per request. Which model choice BEST covers all three?
- ATrain a single-node model such as LightGBM, apply it with mlflow.pyfunc.spark_udf for batch and streaming, and serve the same model on a Model Serving endpoint for the app Correct answer
- BTrain a Spark ML PipelineModel and serve it on a Model Serving endpoint for the app, because Spark ML models give the lowest per-request latency online
- CTrain a Spark ML model for batch and streaming and a separately engineered single-node model for the app, accepting that the two models' feature logic may diverge over time
- DTrain a single-node model and score all 300 million customers by sending them to the Model Serving endpoint in parallel REST calls each night
Answer and explanation: A single-node model logged with MLflow can be distributed for batch and streaming through spark_udf, and the same artifact can be served online with low latency, so one model covers all three paths. Spark ML models carry Spark runtime overhead that is unsuitable for sub-50 ms request serving. Maintaining two different models creates training-serving divergence and double the maintenance. Pushing 300 million rows through REST calls is slow and costly compared with distributed batch scoring.
Question 4 of 10, Model Development
A text classification pipeline must convert free-text support tickets into term-frequency features weighted by how rare each term is across the corpus. Which sequence of Spark ML stages implements this?
- ATokenizer, then IDF, then VectorAssembler, then the classifier
- BTokenizer, then HashingTF, then IDF, then the classifier Correct answer
- CTokenizer, then StringIndexer, then OneHotEncoder, then the classifier
- DHashingTF, then Tokenizer, then StandardScaler, then the classifier
Answer and explanation: Tokenizer splits text into words, HashingTF maps the words to term-frequency vectors, and IDF (an estimator) rescales those counts by inverse document frequency. StringIndexer and OneHotEncoder treat each full ticket as a single category, which is meaningless for free text. IDF requires term-frequency vectors as input, so it cannot follow Tokenizer directly. HashingTF needs tokens as input, so it cannot run before Tokenizer, and StandardScaler does not apply document-frequency weighting.
Question 5 of 10, Model Development
A pandas UDF processes very wide rows and executors run out of memory when converting Arrow batches to pandas. Which setting directly reduces the number of rows in each batch passed to the UDF?
- Aspark.sql.execution.arrow.pyspark.enabled
- Bspark.sql.execution.arrow.maxRecordsPerBatch Correct answer
- Cspark.sql.shuffle.partitions
- Dspark.sql.adaptive.coalescePartitions.enabled
Answer and explanation: spark.sql.execution.arrow.maxRecordsPerBatch caps the rows per Arrow record batch (10,000 by default), so lowering it shrinks each pandas DataFrame handed to the UDF. Shuffle partitions change the partition count after shuffles but not the Arrow batch size. Adaptive partition coalescing merges small shuffle partitions and can even make partitions larger. The arrow.pyspark.enabled flag toggles Arrow for toPandas() and createDataFrame conversions, not the batch size used by pandas UDFs.
Question 6 of 10, MLOps
A deploy models workflow trains in the dev catalog and must move the validated model into prod.ml.churn while preserving lineage to the original training run. Which approach is MOST appropriate?
- AMlflowClient().copy_model_version() from models:/dev.ml.churn/<version> into prod.ml.churn Correct answer
- BRetrain the model in production using the same parameters and register the result as a new version of prod.ml.churn
- CDownload the model artifacts to a volume and run mlflow.register_model() from that volume path into prod.ml.churn
- DRename dev.ml.churn to prod.ml.churn with ALTER MODEL so the existing versions are moved to production instead
Answer and explanation: copy_model_version copies a Unity Catalog model version to another registered model, creating a new version that keeps the reference to its source run, which is how the deploy models pattern promotes artifacts across catalogs. Re-registering from a downloaded path loses the run link. Retraining is the deploy code pattern and does not move the validated artifact. Renaming is not a promotion mechanism: it changes the identity of the whole model and every version, including unvalidated ones, instead of copying one validated version.
Question 7 of 10, MLOps
An organization uses one Unity Catalog metastore with separate dev, staging, and prod workspaces. The MLOps team wants to isolate ML assets by environment while letting production jobs read staging models only when explicitly granted. Which design is MOST appropriate?
- ASeparate catalogs per environment (dev, staging, prod), with grants controlling which principals can read each Correct answer
- BUse a separate metastore per environment so that models in different environments can never be referenced by each other
- CUse one catalog for all environments and distinguish models by adding _dev, _staging, or _prod suffixes to model names
- DUse the workspace-local model registry in each workspace, because Unity Catalog cannot separate assets by environment
Answer and explanation: Separate catalogs per environment, governed by Unity Catalog grants and optional workspace-catalog bindings, give isolation while allowing explicit cross-environment access. Name suffixes in a single catalog give weak isolation and complex permissions. Databricks recommends one metastore per region, and separate metastores would block the desired controlled access. Unity Catalog fully supports environment separation; the workspace registry is legacy.
Question 8 of 10, MLOps
A team needs a custom drift metric that measures the change in the share of null values in the column email between the current window and the baseline. How is a drift custom metric expressed?
- AA SQL query over the raw table filtered by window_start, written to the profile metrics table
- BA Spark ML Evaluator subclass registered on the monitor and evaluated on each refresh window
- CA Python function that receives the two pandas DataFrames and returns one float value for each column
- DA SQL expression referencing aggregate metrics with {{current_df}} and {{base_df}} placeholders Correct answer
Answer and explanation: Drift custom metrics are SQL expressions that reference existing aggregate metrics for the current window and the comparison window through the {{current_df}} and {{base_df}} placeholders, and they are written to the drift metrics table. Monitors do not run arbitrary Python functions. Drift metrics are not raw-table queries and are stored in the drift table, not the profile table. Spark ML evaluators cannot be registered as monitor metrics.
Question 9 of 10, MLOps
A team monitors an inference table and wants the dashboard to show quality metrics per hour for operations and per week for business reviews, computed by the same monitor. Which configuration achieves this?
- ASet granularities to ["1 hour", "1 week"] on the InferenceLog profile Correct answer
- BUse slicing_exprs=["hour(ts)", "weekofyear(ts)"] on the monitor
- CCreate two monitors on the same table with different time zones and window sizes
- DSet the refresh schedule to hourly and weekly in two cron entries
Answer and explanation: A monitor can compute metrics at several granularities at once, and each window size appears separately in the metrics tables and dashboard. Only one monitor can be attached to a table, and time zones do not define windows. Refresh schedules determine when metrics are computed, not the window size. Slicing by hour of day or week of year groups rows by calendar position across all dates, not into time windows.
Question 10 of 10, Model Deployment. Choose 2.
A business-critical endpoint must survive a bad model version without customer impact, and the business wants automatic protection rather than manual monitoring. Which combination is MOST appropriate? (Choose two.)
- AAn automated job that reverts traffic_config when error-rate or latency alerts fire Correct answer
- BA canary rollout with health and quality checks between traffic increases Correct answer
- CTurning off inference tables to avoid exposing bad predictions
- DEnabling scale-to-zero so that a bad version stops consuming compute
- ERemoving the old version as soon as the new one receives traffic
Answer and explanation: Gradual exposure with automated checks limits the impact of a bad version, and an automated rollback that resets traffic when alerts fire removes reliance on manual action. Scale-to-zero affects idle cost, not protection. Removing the old version eliminates the rollback target. Inference tables help detect problems; disabling them reduces visibility.