CertSafari

    Free Databricks Certified Machine Learning Professional Sample Questions

    35 free sample questions from our bank of 330+, covering every exam domain, with answers and detailed explanations. Updated August 2026.

    Domain 1: Model Development Using Spark ML

    1.1 Using Spark ML

    1.Which component is used in Spark ML to define a grid of hyperparameters and construct all the possible combinations to be used by `CrossValidator` or `TrainValidationSplit`?

    1. A.`GridSearcher`
    2. B.`HyperparameterBuilder`
    3. C.`ParamGridBuilder`
    4. D.`EstimatorParamMap`
    Show answer & explanation

    Correct answer: C`ParamGridBuilder`

    • A. Incorrect. `GridSearcher` is not a valid component in the Spark ML library. While the process is called 'grid search,' this specific class name does not exist.
    • B. Incorrect. `HyperparameterBuilder` is a plausible but non-existent class in Spark ML. The library uses a different naming convention for its tuning utilities.
    • C. Correct. `ParamGridBuilder` from the `pyspark.ml.tuning` module is the utility class specifically designed to construct a grid of parameters. It provides methods like `.addGrid()` to specify hyperparameters and their potential values, and its `.build()` method creates the full list of parameter combinations that are then used by `CrossValidator` or `TrainValidationSplit` for model tuning.
    • D. Incorrect. An `EstimatorParamMap` represents a single set of parameters for an Estimator. While `ParamGridBuilder` generates a list of `EstimatorParamMap` objects, it is the builder itself, not the map, that is used to define and construct the entire grid.

    1.1 Using Spark ML

    2.By default, how does the `VectorAssembler` transformer in Spark ML handle rows that contain `null` values in one of the input columns?

    1. A.It imputes the null value with the mean of that column.
    2. B.It skips the rows containing null values.
    3. C.It throws an exception and fails the transformation.
    4. D.It imputes the null value with zero.
    Show answer & explanation

    Correct answer: CIt throws an exception and fails the transformation.

    • A. Incorrect. `VectorAssembler` is a feature transformer responsible for combining columns into a vector; it does not perform data imputation. Imputing with the mean must be done explicitly beforehand, typically using the `Imputer` transformer.
    • B. Incorrect. While `VectorAssembler` can be configured to skip rows with null values by setting its `handleInvalid` parameter to 'skip', this is not the default behavior. The default behavior is to error out.
    • C. Correct. The default value for the `handleInvalid` parameter in `VectorAssembler` is 'error'. Consequently, if it encounters a null value in any of its input columns, it cannot assemble a valid feature vector and will throw a `SparkException`, causing the transformation and the job to fail. This ensures that missing values are explicitly handled by the developer.
    • D. Incorrect. `VectorAssembler` does not impute null values with zero by default. This strategy for handling missing data must be implemented separately, for example, by using the `Imputer` transformer with a `strategy` of 'zero' or by using `DataFrame.na.fill()`.

    1.4 Advanced Feature Store Concepts

    3.You are configuring a feature table of user preferences to be served online for a personalization engine. The data volume is moderate, but the read latency for individual users must be extremely low. Which type of online store is generally recommended by Databricks for this 'key-value' lookup pattern?

    1. A.A Databricks SQL Pro warehouse
    2. B.A hosted MySQL database
    3. C.A NoSQL database like DynamoDB
    4. D.An in-memory cache like Redis
    Show answer & explanation

    Correct answer: CA NoSQL database like DynamoDB

    • A. Incorrect. A Databricks SQL warehouse is an analytical query engine optimized for business intelligence and complex queries over large datasets (OLAP), not for low-latency, single-record key-value lookups required by real-time serving applications.
    • B. Incorrect. While a relational database like MySQL can perform key-value lookups, it is primarily designed for transactional workloads (OLTP) with an emphasis on consistency. It typically cannot match the extremely low latency and high-throughput read performance of specialized NoSQL or in-memory systems for this use case.
    • C. Correct. NoSQL databases, and specifically key-value stores like Amazon DynamoDB or Azure Cosmos DB, are purpose-built for this exact pattern. They provide single-digit millisecond latency for fetching individual records at a massive scale, making them the standard and generally recommended choice for hosting online feature stores in production.
    • D. Incorrect. While an in-memory cache like Redis offers extremely low latency, it is often used as a caching layer in front of a persistent database rather than the primary online store itself. A managed NoSQL database provides a more robust and persistent solution out-of-the-box, which is critical for a production feature store, making it a better general recommendation.

    1.4 Advanced Feature Store Concepts

    4.A data scientist has developed a feature engineering pipeline that computes complex user session aggregations. The code is in a notebook and uses `fe.write_features(session_features_df, name='prod.features.user_sessions', mode='merge')`. The lead MLOps engineer reviews the code and suggests replacing `write_features` with a direct Delta Lake `MERGE` operation for better performance. What is a key disadvantage of this suggestion?

    1. A.Direct Delta `MERGE` operations do not support schema evolution.
    2. B.It bypasses the Feature Store's metadata tracking, making feature lineage and discovery more difficult.
    3. C.A direct Delta `MERGE` operation cannot be executed from a Databricks notebook.
    4. D.The performance of a direct Delta `MERGE` is always worse than `fe.write_features`.
    Show answer & explanation

    Correct answer: BIt bypasses the Feature Store's metadata tracking, making feature lineage and discovery more difficult.

    • A. Incorrect. Delta Lake `MERGE` operations fully support schema evolution when properly configured (e.g., using `option("mergeSchema", "true")`). This allows the target table's schema to adapt to changes in the source data during a merge, making this option an invalid disadvantage.
    • B. Correct. This is the primary disadvantage. The `fe.write_features` method is a high-level API that not only writes data to the underlying Delta table but also crucially updates the Feature Store's metadata. Bypassing this by using a direct Delta `MERGE` means the Feature Store will not track feature lineage, versioning, or other critical metadata. This severely hampers feature discovery, governance, and reproducibility, which are the core benefits of using a Feature Store.
    • C. Incorrect. Direct Delta Lake `MERGE` operations can be executed from Databricks notebooks using either SQL commands (`%sql`) or PySpark DataFrame APIs (`deltaTable.alias(...).merge(...)`). There are no restrictions preventing this.
    • D. Incorrect. This statement is contrary to the MLOps engineer's suggestion. While `fe.write_features` with `mode='merge'` likely uses a `MERGE` operation under the hood, a direct, manually tuned `MERGE` operation can sometimes offer better performance. The key trade-off is sacrificing the Feature Store's management capabilities for potential performance gains.

    1.4 Advanced Feature Store Concepts

    5.A team has a streaming feature pipeline that calculates user aggregates. During a period of high load, the pipeline falls behind. When it catches up, they notice that feature values for a specific user seem to jump back and forth in time. This is causing issues with downstream models. What streaming concept is essential to correctly handle such out-of-order data during stateful aggregations?

    1. A.Setting a checkpoint location
    2. B.Using a watermark on the event-time column
    3. C.Increasing the trigger interval
    4. D.Using `outputMode('append')`
    Show answer & explanation

    Correct answer: BUsing a watermark on the event-time column

    • A. Incorrect. Setting a checkpoint location is crucial for fault tolerance and recovery in stateful streaming applications. It allows the pipeline to resume from where it left off after a failure. However, it does not address the core logic of handling out-of-order data based on event time.
    • B. Correct. Using a watermark on an event-time column is the standard mechanism in Spark Structured Streaming for handling late or out-of-order data. A watermark defines a time-based threshold, informing the engine how long to wait for late data before finalizing an aggregation and evicting the corresponding state. This prevents older, late-arriving data from modifying already-calculated aggregates, thus solving the problem of feature values jumping back in time.
    • C. Incorrect. Increasing the trigger interval changes how frequently the streaming query processes incoming data into micro-batches. While this can help manage load by processing larger batches less often, it does not solve the fundamental problem of correctly ordering events and managing state for out-of-order data.
    • D. Incorrect. The output mode, such as `append`, `update`, or `complete`, determines how the results of the streaming query are written to the output sink. While `append` mode is often used with watermarking for windowed aggregations, it is the watermark itself, not the output mode, that handles the logic for late data and state management.

    1.3 Advanced MLflow Usage

    6.A model's output is a probability score, but the business requirement is to return one of three string labels: 'LOW', 'MEDIUM', or 'HIGH', based on custom thresholds (e.g., <0.3, 0.3-0.7, >0.7). The underlying model is a LightGBM classifier. What is the most robust way to package this model and the thresholding logic for deployment?

    1. A.Log the LightGBM model directly and have the downstream application implement the thresholding logic by receiving the raw probability scores and applying the custom thresholds to map each score to 'LOW', 'MEDIUM', or 'HIGH'.
    2. B.Log the thresholds as model parameters using `mlflow.log_params()` and then load them in a custom inference script that applies the mapping to the LightGBM probability output, returning the string labels.
    3. C.Create a custom `mlflow.pyfunc` model that loads the LightGBM model. Its `predict` method calls the LightGBM model's `predict_proba`, applies the thresholding logic, and returns the final string labels.
    4. D.Save the thresholding logic in a separate Python script and log it as an artifact, then load the script alongside the LightGBM model in a deployment wrapper that calls the script to convert probabilities to string labels.
    Show answer & explanation

    Correct answer: CCreate a custom `mlflow.pyfunc` model that loads the LightGBM model. Its `predict` method calls the LightGBM model's `predict_proba`, applies the thresholding logic, and returns the final string labels.

    • A. Incorrect. This approach decouples the thresholding logic from the model, forcing every downstream application to reimplement the mapping. It leads to code duplication, potential inconsistencies, and increased maintenance overhead if thresholds change.
    • B. Incorrect. Logging thresholds as parameters tracks them but does not embed the transformation into the model artifact. The model still outputs raw probabilities, requiring a separate process to apply the mapping, which adds complexity and risk of misalignment.
    • C. Correct. A custom `mlflow.pyfunc` model encapsulates the LightGBM model and thresholding logic into a single deployable artifact. Its `predict` method returns the final string labels, ensuring consistent, error-free consumption by any downstream application.
    • D. Incorrect. Logging the logic as a separate artifact does not integrate it into the model's prediction interface. Deployment becomes more complex and fragile, as consumers must locate, load, and correctly apply the script, increasing the risk of version mismatches.

    1.3 Advanced MLflow Usage

    7.While orchestrating a complex data processing and training job with nested runs, you want to pass an intermediate data path from a parent run to a child run. What is the recommended way to do this?

    1. A.The child run can programmatically access the parent's parameters by calling `mlflow.get_run(parent_run_id)` and extracting the intermediate data path from the returned run object.
    2. B.This is not possible because child runs are completely isolated from parent runs, so no data path can be passed between them during orchestration.
    3. C.The orchestration code that creates the child run should pass the path as an argument to the child run's function, which then logs it as its own parameter.
    4. D.Write the path to a shared DBFS location, such as `/dbfs/mnt/intermediate_data`, and have the child run read it from there by accessing the same mount point.
    Show answer & explanation

    Correct answer: CThe orchestration code that creates the child run should pass the path as an argument to the child run's function, which then logs it as its own parameter.

    • A. Incorrect. While a child run can programmatically access the parent's parameters by calling `mlflow.get_run(parent_run_id)`, this is an anti-pattern. It creates tight coupling where the child run's logic depends on the parent's implementation details, inverting the expected control flow and making the workflow harder to understand and maintain.
    • B. Incorrect. This statement is false. Nested runs in MLflow are designed to create a hierarchical relationship, not complete isolation. The orchestrating code can and should pass information between parent and child runs.
    • C. Correct. This is the recommended and most robust approach. The orchestration code that creates the child run should explicitly pass the path as an argument to the child run's function, which then logs it as its own parameter. This makes the data dependency clear, explicit, and self-documenting, promoting modularity and reusability.
    • D. Incorrect. Although writing the path to a shared DBFS location can work, it is not recommended. Using a shared file location as an indirect communication channel introduces an external state dependency, which is less explicit, more error-prone, and can lead to issues like race conditions or synchronization problems, making the workflow less reliable.

    1.2 Scaling and Tuning

    8.A data scientist has written a PySpark job to perform inference using a pre-trained scikit-learn model. The current implementation uses a standard row-at-a-time UDF. The performance is poor due to high serialization overhead. What is the most effective refactoring to improve performance?

    1. A.Increase the `spark.driver.memory` to allow the driver to hold larger serialized payloads when the UDF transfers data between the JVM and Python worker.
    2. B.Replace the row-at-a-time UDF with a Pandas UDF (e.g., using `@pandas_udf`) to enable vectorized, batch-wise execution with Apache Arrow.
    3. C.Cache the DataFrame using `df.cache()` before applying the UDF so that the serialized rows are stored in memory and reused across executor tasks in this workflow.
    4. D.Repartition the DataFrame into a larger number of partitions to increase parallelism, allowing more executor tasks to process serialized rows concurrently.
    Show answer & explanation

    Correct answer: BReplace the row-at-a-time UDF with a Pandas UDF (e.g., using `@pandas_udf`) to enable vectorized, batch-wise execution with Apache Arrow.

    • A. Incorrect. Increasing `spark.driver.memory` only expands memory on the driver node, which is not where UDF execution occurs. The performance bottleneck is the high serialization cost of transferring data row-by-row between the JVM and Python processes on the executor nodes. This change does not address the root cause of the inefficiency.
    • B. Correct. Replacing the row-at-a-time UDF with a Pandas UDF (e.g., using `@pandas_udf`) enables vectorized, batch-wise execution with Apache Arrow. This drastically reduces serialization overhead by transferring data in batches (Pandas Series) instead of individual rows, and allows for vectorized computations, leading to significant performance gains.
    • C. Incorrect. Caching the DataFrame with `df.cache()` is beneficial when the DataFrame is reused in multiple subsequent actions, as it avoids recomputation. However, it does not improve the performance of the UDF application itself. The high serialization overhead of the row-at-a-time UDF will still be incurred when processing the cached data.
    • D. Incorrect. Repartitioning the DataFrame into a larger number of partitions can increase parallelism, but it does not address the fundamental inefficiency of the row-at-a-time UDF. The serialization overhead is a per-row cost, and simply processing more rows in parallel across smaller partitions does not reduce this cost. In fact, it can introduce additional overhead from shuffling data and managing more tasks.

    1.2 Scaling and Tuning

    9.You are distributing an Optuna study using `hyperopt.SparkTrials`. The objective function occasionally fails for certain hyperparameter combinations, raising an exception. What is the best practice for handling these exceptions within the objective function to ensure the overall tuning process does not stop?

    1. A.Let the exception propagate to the Spark driver, where `SparkTrials` automatically catches it and marks the trial as pruned, allowing the study to continue with the next hyperparameter combination.
    2. B.Wrap the core logic in a try/except block. In the except block, log the error and return a large value like `float('inf')` to signal to Optuna that it was a bad trial.
    3. C.Configure `spark.task.maxFailures` to a high number so that Spark retries the failed task multiple times before marking the trial as failed, which prevents the study from stopping on transient errors.
    4. D.In the except block, call `sys.exit(0)` to terminate the current task gracefully, relying on Spark's task retry mechanism to reschedule the trial without propagating the exception to the driver.
    Show answer & explanation

    Correct answer: BWrap the core logic in a try/except block. In the except block, log the error and return a large value like `float('inf')` to signal to Optuna that it was a bad trial.

    • A. Incorrect. Letting the exception propagate to the Spark driver will cause the Spark task to fail. While Spark may retry the task, repeated failures can lead to the entire job being terminated. `SparkTrials` does not automatically catch the exception and mark the trial as pruned; it simply loses the result, which can destabilize the tuning process.
    • B. Correct. Wrapping the core logic in a try/except block prevents the Spark task from crashing. Returning a large value like `float('inf')` (for minimization) explicitly signals to Optuna that this hyperparameter combination is poor, allowing the study to continue and the sampler to avoid that region of the search space.
    • C. Incorrect. Configuring `spark.task.maxFailures` to a high number addresses transient issues like node failures, not deterministic application-level errors. Since the exception is caused by a specific hyperparameter combination, retrying will result in the same failure, wasting resources and providing no useful feedback to Optuna's sampler.
    • D. Incorrect. Calling `sys.exit(0)` in the except block is not a graceful way to handle the exception within a distributed Spark task. It can abruptly terminate the Python interpreter on the worker, potentially causing the entire Spark executor to fail and disrupting the job, while providing no feedback to the Optuna study about the trial's outcome.

    1.1 Using Spark ML

    10.A start-up is building its first-ever product recommendation model. The entire user-item interaction dataset is 50 MB. The data science team is most proficient with Python and libraries like pandas and scikit-learn. In this scenario, what is the most pragmatic initial approach?

    1. A.Immediately provision a large Spark cluster and build a Spark ML ALS model, leveraging distributed training to handle potential growth beyond the current 50 MB dataset.
    2. B.Use single-node libraries like scikit-learn or surprise on a standard Databricks node, as the data fits comfortably in memory and allows for rapid iteration.
    3. C.Convert the data to Parquet and use Spark SQL to perform all manipulations before training a Spark ML model, leveraging columnar storage for efficient feature engineering.
    4. D.Insist on a streaming solution using Spark Structured Streaming to process user-item interactions in real time, preparing the system for immediate updates as the product gains users.
    Show answer & explanation

    Correct answer: BUse single-node libraries like scikit-learn or surprise on a standard Databricks node, as the data fits comfortably in memory and allows for rapid iteration.

    • A. Incorrect. Immediately provisioning a large Spark cluster for a 50 MB dataset is unnecessary overkill. It introduces significant cost and operational complexity without providing any benefit, as the data can easily be processed on a single machine. Planning for future scalability is important, but not at the cost of pragmatic initial development.
    • B. Correct. This is the most pragmatic approach. The 50 MB dataset fits comfortably in the memory of a single standard Databricks node. This allows the team to leverage their existing proficiency with single-node Python libraries like scikit-learn or surprise, enabling rapid prototyping, experimentation, and iteration without the unnecessary overhead of a distributed system.
    • C. Incorrect. While converting to Parquet and using Spark SQL is a best practice for large datasets, it introduces needless complexity and overhead for a 50 MB dataset. The team can work much faster and more efficiently by loading the data directly into a pandas DataFrame on a single node.
    • D. Incorrect. This is an example of premature optimization. Insisting on a streaming solution using Spark Structured Streaming before validating the initial model on a static dataset adds significant complexity. The immediate goal is to build a first version of the model; a streaming architecture can be considered later if and when the need for real-time data processing arises and is justified by business requirements.

    1.3 Advanced MLflow Usage

    11.A feature engineering script is the first stage in your pipeline and is tracked as a nested run. The script produces a cleaned Delta table. What is the most effective way to log the output of this run so that subsequent stages can use it?

    1. A.Log the entire contents of the output Delta table as a single, versioned artifact to ensure data is fully encapsulated.
    2. B.Log the path and version of the output Delta table as tags or parameters on the feature engineering run.
    3. C.Log the schema of the output Delta table as a parameter, recording column names and data types for downstream validation.
    4. D.Log a sample of the output Delta table as a dictionary artifact, storing a representative subset of rows for inspection.
    Show answer & explanation

    Correct answer: BLog the path and version of the output Delta table as tags or parameters on the feature engineering run.

    • A. Incorrect. Logging the entire contents of a Delta table as a single artifact is highly inefficient and impractical, especially for large datasets. This approach would duplicate data, consume significant storage, and create performance bottlenecks. MLflow artifacts are better suited for smaller objects like models or configuration files, not full-scale datasets.
    • B. Correct. Logging the path and version of the output Delta table as tags or parameters is a lightweight and efficient best practice for managing data lineage in ML pipelines on Databricks. It allows subsequent stages to reliably and reproducibly load the exact version of the data created by this run without duplicating the data itself.
    • C. Incorrect. While logging the schema as a parameter provides useful metadata about the data's structure, it is insufficient on its own. A downstream process needs the location (path and version) of the table to actually read and use the data; the schema alone does not provide access to the dataset.
    • D. Incorrect. Logging a sample of the output as a dictionary artifact may be useful for quick inspection or debugging, but it does not provide the complete dataset. Subsequent stages that require the full cleaned dataset for tasks like model training or validation cannot rely on a representative subset alone.

    1.2 Scaling and Tuning

    12.An `applyInPandas` job is failing due to data skew, causing OOM errors on executors handling the largest groups. You cannot change the underlying data distribution. Which common technique can be applied during data processing to mitigate this issue?

    1. A.Salting the key: Add a random suffix to the skewed group keys to break a single large group into multiple smaller ones.
    2. B.Caching the DataFrame with `StorageLevel.MEMORY_AND_DISK_SER` so that large, skewed partitions can spill to disk and reduce memory pressure.
    3. C.Setting `spark.sql.shuffle.partitions` to a smaller number to reduce the task count, thereby allocating more executor memory to each task.
    4. D.Using a broadcast hint on the skewed DataFrame to replicate its data to all executors and thereby bypass the shuffle causing the OOM errors.
    Show answer & explanation

    Correct answer: ASalting the key: Add a random suffix to the skewed group keys to break a single large group into multiple smaller ones.

    • A. Correct. Salting the key by adding a random suffix to skewed group keys breaks a single large group into multiple smaller ones, distributing the processing load across executors. This directly addresses data skew, preventing OOM errors on executors that would otherwise handle disproportionately large groups.
    • B. Incorrect. Caching with `StorageLevel.MEMORY_AND_DISK_SER` stores data for reuse but does not alter partitioning or group sizes. It cannot mitigate data skew because the same large groups are still processed by single executors, so OOM errors persist.
    • C. Incorrect. Reducing `spark.sql.shuffle.partitions` creates fewer, larger partitions, which would combine skewed groups into even bigger tasks. This worsens memory pressure on executors and increases the likelihood of OOM errors, rather than alleviating them.
    • D. Incorrect. A broadcast hint is used for joins to replicate a small DataFrame to all executors, avoiding a shuffle. It does not apply to `applyInPandas` operations on a single DataFrame and cannot resolve data skew within groups.

    Domain 2: MLOps Model Lifecycle Management

    2.1 Model Lifecycle Management

    13.Which Databricks feature is specifically designed to version control and manage the lifecycle of trained machine learning models, including their transitions between environments like 'Staging' and 'Production'?

    1. A.Databricks Repos
    2. B.Delta Lake Time Travel
    3. C.MLflow Model Registry
    4. D.Databricks Jobs
    Show answer & explanation

    Correct answer: CMLflow Model Registry

    • A. Incorrect. Databricks Repos provides Git integration within the workspace. It is used for version controlling source code, notebooks, and other project files, but not for managing the lifecycle of the trained model artifacts themselves.
    • B. Incorrect. Delta Lake Time Travel is a data versioning feature that allows you to access and query historical versions of data stored in Delta tables. It is for managing data, not the lifecycle of machine learning models.
    • C. Correct. The MLflow Model Registry is a centralized repository specifically designed to manage the end-to-end lifecycle of MLflow Models. It provides model versioning, stage transitions (e.g., Staging, Production, Archived), and annotations, making it the purpose-built tool for model governance and deployment.
    • D. Incorrect. Databricks Jobs is a workflow orchestration tool used to schedule and run notebooks, scripts, and other tasks. While a job might be used to train a model or run inference, it does not provide features for versioning or managing the model's lifecycle stages.

    2.1 Model Lifecycle Management

    14.An ML engineer wants to programmatically fetch the run ID of the MLflow run that created a specific model version (e.g., version 5 of 'Sales-Forecast'). How can this be achieved using the `MlflowClient`?

    1. A.client.search_runs(experiment_ids=['1'], filter_string="tags.mlflow.source.name = 'Sales-Forecast/5'")
    2. B.client.get_model_version(name='Sales-Forecast', version='5').run_id
    3. C.client.get_run(model_name='Sales-Forecast', version='5').info.run_id
    4. D.client.search_model_versions(filter_string="name='Sales-Forecast' AND version='5'")
    Show answer & explanation

    Correct answer: Bclient.get_model_version(name='Sales-Forecast', version='5').run_id

    • A. This option is incorrect. While `search_runs` can filter runs based on tags, there is no guarantee that a tag with the specific format `'Sales-Forecast/5'` exists or is reliably associated with the model version. It's not the direct or standard method for this task.
    • B. This is the correct and most direct method. The `MlflowClient.get_model_version()` function is specifically designed to retrieve a `ModelVersion` object by its registered name and version number. This object contains metadata about the model version, including the `run_id` attribute, which directly provides the ID of the run that created it.
    • C. This option is incorrect because the `MlflowClient.get_run()` method's signature is wrong. This method requires a `run_id` as its primary argument to fetch run details. It does not accept `model_name` or `version` as parameters.
    • D. This option is less direct than the correct answer. The `search_model_versions()` method returns a list-like `PagedList` of `ModelVersion` objects that match the filter. While it can find the correct model version, it requires an additional step to index the result (e.g., `result[0]`) and then access the `.run_id` attribute, making it more verbose than the `get_model_version` approach.

    2.2 Validation Testing

    15.Which type of testing is primarily concerned with verifying the correctness of individual, isolated Python functions or Spark UDFs?

    1. A.Integration Testing
    2. B.End-to-End Testing
    3. C.Unit Testing
    4. D.Stress Testing
    Show answer & explanation

    Correct answer: CUnit Testing

    • A. Incorrect. Integration testing focuses on verifying the interactions and data flow between multiple components or systems after they have been integrated. It is concerned with how units work together, not with the correctness of individual, isolated functions.
    • B. Incorrect. End-to-end testing validates the entire application workflow from start to finish, simulating real user scenarios to ensure all integrated components of the system function together as expected. It is a holistic test of the entire system, not isolated units.
    • C. Correct. Unit testing is specifically designed to test the smallest testable parts of an application, called 'units' (e.g., individual Python functions, methods, or Spark UDFs), in isolation from the rest of the application. Its primary goal is to verify that each unit of code performs its specific operation correctly.
    • D. Incorrect. Stress testing is a type of non-functional testing that evaluates a system's robustness and stability under extreme or heavy load conditions. Its focus is on performance and reliability under pressure, not the functional correctness of individual code units.

    2.3 Environment Architectures

    16.Which of the following Databricks assets CANNOT be directly defined and managed as a top-level resource key within the `resources` block of a `databricks.yml` file?

    1. A.jobs
    2. B.model_serving_endpoints
    3. C.mlflow_experiments
    4. D.unity_catalog_metastores
    Show answer & explanation

    Correct answer: Dunity_catalog_metastores

    • A. Incorrect. `jobs` is a standard and frequently used top-level resource key within the `resources` block of a `databricks.yml` file. It allows for the declarative definition and management of Databricks Jobs, including their tasks, cluster configurations, and schedules as part of a Databricks Asset Bundle.
    • B. Incorrect. `model_serving_endpoints` is a supported top-level resource key in a `databricks.yml` file. This key is used to define, configure, and manage Model Serving endpoints, specifying which registered models to serve and the compute resources to use, facilitating CI/CD for model deployment.
    • C. Incorrect. While the exact key name is `experiments` and not `mlflow_experiments`, MLflow experiments are a manageable resource type within `databricks.yml`. The `experiments` key allows for the definition of MLflow experiments, including their name and creation path, as part of an automated bundle deployment.
    • D. Correct. A `unity_catalog_metastores` is a high-level, foundational resource that is managed at the Databricks account level, not within a workspace-specific project or Databricks Asset Bundle. A metastore must already exist and be attached to a workspace before bundle assets can be deployed. Therefore, it cannot be defined as a resource within a `databricks.yml` file.

    2.5 Drift Detection and Lakehouse Monitoring

    17.A model predicting housing prices uses `zip_code` as a key feature. The Lakehouse Monitor flags significant drift on this feature using the Chi-Squared test. However, downstream business KPIs and model accuracy metrics have remained stable. Which is the most plausible explanation for this observation?

    1. A.The Chi-Squared test is unreliable for high-cardinality categorical features and should be ignored.
    2. B.The observed drift is real (e.g., more sales data from new, developing zip codes), but the model has learned a robust representation that generalizes well to these new distributions.
    3. C.The monitoring pipeline is misconfigured, likely comparing the baseline to itself, leading to false positives.
    4. D.The model has become stale and is now outputting random predictions, which coincidentally maintain the same overall accuracy.
    Show answer & explanation

    Correct answer: BThe observed drift is real (e.g., more sales data from new, developing zip codes), but the model has learned a robust representation that generalizes well to these new distributions.

    • A. Incorrect. The Chi-Squared test is a standard statistical method for detecting changes in the distribution of categorical features. While it can be sensitive with high-cardinality features on large datasets, flagging even small changes as statistically significant, it is not inherently unreliable. Ignoring the alert without investigation is poor MLOps practice.
    • B. Correct. This is the most plausible scenario. It acknowledges both observations: the data drift is real, as correctly identified by the Chi-Squared test, but the model's performance is unaffected. This indicates the model is robust and generalizes well. For example, the model may have learned underlying patterns related to other features correlated with zip codes (like area affluence or school quality) that hold true even for new, previously unseen zip codes.
    • C. Incorrect. This explanation is logically flawed. If the monitoring pipeline were misconfigured to compare the baseline data against itself, the distributions would be identical, and no statistical drift would be detected. The scenario explicitly states that the monitor *did* flag a significant drift, contradicting this option.
    • D. Incorrect. This is highly improbable. If a model became stale and started generating random predictions, a sharp degradation in accuracy metrics and business KPIs would be expected. The observation that these metrics have remained stable makes this explanation extremely unlikely.

    2.5 Drift Detection and Lakehouse Monitoring

    18.You are setting up an `InferenceLog` monitor for a newly deployed classification model. The table contains `prediction`, `label`, `timestamp`, and `model_version` columns. Which parameter in the `databricks.lakehouse_monitoring.create_monitor` call is essential for the monitor to automatically track and compare performance metrics like accuracy across different deployed model versions?

    1. A.timestamp_col='timestamp'
    2. B.slicing_exprs=['model_version']
    3. C.model_version_col='model_version'
    4. D.label_col='label'
    Show answer & explanation

    Correct answer: Cmodel_version_col='model_version'

    • A. Incorrect. The `timestamp_col` parameter is crucial for analyzing how model performance or data drifts over time. However, it does not provide the mechanism to group, segment, or compare metrics specifically by model version.
    • B. Incorrect. While `slicing_exprs` is a powerful, general-purpose parameter for creating custom data segments for analysis, it is not the primary or dedicated parameter for version-over-version performance tracking. The monitor has a specific parameter intended for this common MLOps task, which enables more specialized and automatic version-aware features.
    • C. Correct. The `model_version_col` (documented as `model_id_col`) is the essential parameter that explicitly tells Lakehouse Monitoring which column contains the model version identifier. Specifying this enables the monitor to automatically group metrics by version, allowing for direct comparison of performance metrics like accuracy across different deployed model versions in the generated dashboards.
    • D. Incorrect. The `label_col` is necessary for calculating classification performance metrics like accuracy, as it points to the ground truth column. However, it does not enable the comparison of these metrics across different model versions; it only provides the data needed for the calculation itself.

    2.5 Drift Detection and Lakehouse Monitoring

    19.Which statistical test is used by Databricks Lakehouse Monitoring to measure distribution drift for categorical features?

    1. A.`Kolmogorov-Smirnov (K-S) test`
    2. B.`Population Stability Index (PSI)`
    3. C.`Chi-Squared test`
    4. D.`Anderson-Darling test`
    Show answer & explanation

    Correct answer: C`Chi-Squared test`

    • A. Incorrect. According to Databricks documentation, the Kolmogorov-Smirnov (K-S) test is used by Lakehouse Monitoring to detect drift between two distributions, but specifically for `numeric` columns, not categorical ones.
    • B. Incorrect. The Population Stability Index (PSI) is a metric calculated by Lakehouse Monitoring to measure drift in `numeric` columns only. The official documentation states that the PSI value is `null` for categorical columns.
    • C. Correct. The official Databricks documentation for Lakehouse Monitoring (now Data Quality Monitoring) explicitly states that the Chi-Squared test is used to detect distribution drift for `categorical` columns. This test assesses whether observed frequencies in categories differ significantly from a baseline.
    • D. Incorrect. While the Anderson-Darling test is a valid statistical test used to determine if a sample of data is drawn from a given probability distribution, it is not listed in the Databricks documentation as a method used by Lakehouse Monitoring for drift detection.

    2.4 Automated Retraining

    20.A team is monitoring feature drift for a real-time bidding model using Databricks Lakehouse Monitoring. The monitor is configured to check for drift on an hourly basis. A critical feature, `user_time_on_site`, shows a significant and sudden drift, causing the Population Stability Index (PSI) to exceed the configured alert threshold. The automated retraining pipeline is triggered. However, the operations team discovers the drift was caused by an upstream data pipeline error that started feeding null values into the feature. What is the most appropriate design for the automated retraining workflow to handle this situation?

    1. A.The workflow should automatically proceed with retraining using the drifted data, treating the null values as a legitimate feature state that reflects a new user behavior pattern. The model can learn to associate nulls with specific outcomes.
    2. B.The workflow should have a preliminary data validation step. Upon detecting an abnormally high null percentage for a key feature, it should halt the retraining process and send a high-priority alert to the MLOps team for manual investigation.
    3. C.The workflow should automatically roll back the production model to a version from three months ago, assuming that the older model's performance metrics remain stable and unaffected by the upstream data pipeline error. This rollback restores the model to a state before the drift occurred.
    4. D.The workflow should ignore the drifted feature during the retraining process and build a new model on the remaining features, treating the null values as missing data that can be excluded without affecting model accuracy. The retraining pipeline drops the problematic feature entirely.
    Show answer & explanation

    Correct answer: BThe workflow should have a preliminary data validation step. Upon detecting an abnormally high null percentage for a key feature, it should halt the retraining process and send a high-priority alert to the MLOps team for manual investigation.

    • A. Incorrect. Retraining on data corrupted by an upstream error is a poor practice known as 'garbage in, garbage out.' The model would learn from an invalid data distribution (the high percentage of nulls), leading to degraded performance and unreliable predictions once the data issue is fixed.
    • B. Correct. This is a recommended MLOps best practice on Databricks. According to Databricks documentation, workflows should include data quality checks before retraining. Databricks features like Delta Live Tables with `expectations` and `ON VIOLATION FAIL UPDATE` or multi-task Databricks Jobs can be used to validate data and halt the pipeline on failure. Alerts can then be sent via Databricks SQL Alerts or job notifications to enable manual intervention.
    • C. Incorrect. Rolling back to a much older model is a drastic, reactive measure and not a standard procedure for handling data quality issues. This approach does not address the root cause of the data corruption, and the older model may be significantly stale, leading to poor performance on current data.
    • D. Incorrect. While feature exclusion can be a fallback strategy, it is not the most appropriate initial response. The feature is described as 'critical,' so removing it would likely degrade the model's predictive power. The best practice is to first identify and fix the data quality issue rather than working around it by discarding important information.

    2.1 Model Lifecycle Management

    21.A company has a central Databricks workspace for production and separate workspaces for each development team. A CI/CD pipeline needs to promote a model from a development workspace's registry to the central production workspace's registry. How can MLflow be configured to handle this cross-workspace registration?

    1. A.This limitation can be addressed by exporting the model from the dev workspace registry as a Docker container and then importing that container into the production workspace registry using the MLflow CLI, which allows cross-workspace model promotion.
    2. B.By setting the `MLFLOW_TRACKING_URI` to the production workspace's URI and using credentials with permissions for both workspaces, the pipeline can load the model from the dev workspace and register it in the prod workspace.
    3. C.By downloading the model artifact from the dev workspace registry and then using the MLflow Client to upload it to the production workspace registry with a new registered model name, the pipeline can transfer the model without direct workspace integration.
    4. D.By using Databricks Repos to sync the model artifact files between the workspaces and then invoking the MLflow Tracking API to register the synced artifact in the production workspace registry, the model becomes available for serving in the central environment.
    Show answer & explanation

    Correct answer: BBy setting the `MLFLOW_TRACKING_URI` to the production workspace's URI and using credentials with permissions for both workspaces, the pipeline can load the model from the dev workspace and register it in the prod workspace.

    • A. Incorrect. Exporting a model as a Docker container and importing it via the MLflow CLI is not a standard or efficient method for cross-workspace model promotion. MLflow provides direct APIs to register models across workspaces without containerization, making this approach unnecessarily complex and not aligned with typical CI/CD practices.
    • B. Correct. By setting `MLFLOW_TRACKING_URI` to the production workspace and using credentials with appropriate permissions, the pipeline can load the model from the dev workspace and register it directly in the prod workspace. This leverages MLflow's built-in cross-workspace capabilities, enabling a seamless, automated promotion process.
    • C. Incorrect. While downloading and re-uploading model artifacts is technically possible, it is a manual, error-prone process that undermines CI/CD automation. MLflow's client can directly register models across workspaces without intermediate artifact transfers, making this method inefficient and not recommended for production pipelines.
    • D. Incorrect. Databricks Repos is designed for source code versioning, not for managing ML model artifacts or interacting with the Model Registry. Using Repos to sync model files and then registering them via the Tracking API is an indirect and unsupported approach that bypasses MLflow's intended cross-workspace registration mechanisms.

    2.2 Validation Testing

    22.Which statement best describes the role of validation testing in the 'Prod' environment?

    1. A.It is where all unit and integration tests should be run for the first time, using the production environment as the primary validation stage before any release.
    2. B.No testing should occur in 'Prod'; it is only for serving live traffic, with all validation activities confined to pre-production environments that mirror production configuration.
    3. C.This stage focuses on monitoring and smoke testing, such as checking if a newly deployed model endpoint is responsive and returning predictions in the correct format.
    4. D.It involves running large-scale integration tests on the entire production database to find bugs, such as verifying data consistency across all tables after a schema migration.
    Show answer & explanation

    Correct answer: CThis stage focuses on monitoring and smoke testing, such as checking if a newly deployed model endpoint is responsive and returning predictions in the correct format.

    • A. Incorrect. Unit and integration tests are foundational tests performed early in the development lifecycle, within development or staging environments. Running them for the first time in production introduces significant risk of deploying faulty code and causing instability or outages for live users.
    • B. Incorrect. While the production environment's primary purpose is serving live traffic, some testing is essential post-deployment. This includes health checks, smoke tests to verify basic functionality, and ongoing monitoring to ensure the system operates correctly and reliably.
    • C. Correct. In a production environment, validation testing shifts to focus on post-deployment verification. This typically includes smoke tests to confirm that the service (e.g., a model endpoint) is responsive and that its basic functionality works as expected, such as returning a prediction with the correct data schema. It is also intrinsically linked to monitoring for the ongoing health and performance of the deployed model.
    • D. Incorrect. Running large-scale integration tests directly on a production database can severely impact performance, risk data corruption, and affect live users. Such comprehensive testing should be conducted in a dedicated pre-production or staging environment that mirrors the production setup without impacting it.

    2.1 Model Lifecycle Management

    23.A financial services company needs to ensure that all models deployed to production have been validated by a human from the compliance team. How can this manual approval step be integrated into an otherwise automated model lifecycle pipeline?

    1. A.The deployment pipeline pauses before promoting a model to production and sends an approval request to the compliance team via email, resuming only after a designated officer replies with an authorized confirmation that includes the model version and a unique validation token.
    2. B.A model webhook is configured to call an external service (e.g., a ServiceNow workflow) when a model is transitioned to 'Staging'. The service handles the approval process and uses the MLflow API to transition the model to 'Production' upon approval.
    3. C.The compliance officer is granted 'Can Manage Production Versions' permission in the MLflow registry and follows a documented procedure to manually transition a model from 'Staging' to 'Production' in the UI after completing a review checklist and signing off on the model's validation report.
    4. D.The deployment job is scheduled to run nightly, automatically promoting the latest validated model to production. The compliance team then reviews deployment logs and model metrics the next morning, initiating a rollback via the MLflow API if any compliance issues are found.
    Show answer & explanation

    Correct answer: BA model webhook is configured to call an external service (e.g., a ServiceNow workflow) when a model is transitioned to 'Staging'. The service handles the approval process and uses the MLflow API to transition the model to 'Production' upon approval.

    • A. Incorrect. Pausing the pipeline and waiting for an email reply is brittle and insecure, as it relies on manual intervention outside the automated system. This approach lacks integration with the model registry, making it difficult to audit and trace approvals systematically.
    • B. Correct. Using a model webhook to trigger an external service like ServiceNow upon transition to 'Staging' formally integrates the human approval step. The service manages the review and programmatically promotes the model to 'Production' via the MLflow API, maintaining end-to-end automation and full auditability.
    • C. Incorrect. Granting the compliance officer permission to manually transition the model in the UI disconnects the approval from the automated pipeline. This manual process is error-prone, not scalable, and hinders auditing within the context of a specific pipeline run.
    • D. Incorrect. Automatically promoting a model to production and reviewing compliance afterward violates the requirement for pre-deployment validation. In a regulated financial environment, deploying an unapproved model and relying on a rollback is unacceptable and introduces significant risk.

    2.4 Automated Retraining

    24.A retailer's automated retraining pipeline for a pricing model evaluates candidate models on standard metrics like Mean Absolute Error (MAE). However, business stakeholders are ultimately concerned with the model's impact on profit margin. The MLOps team has built a simulation environment that can estimate the profit margin for a given set of model predictions. How can this business-centric metric be best integrated into the automated model selection process?

    1. A.Stick to using MAE for automated promotion, but integrate a weekly automated simulation step that calculates the profit margin for the candidate model and includes it in a report for stakeholder review before final approval. The simulation runs on a holdout set of recent transactions.
    2. B.Add a step in the retraining workflow that runs the profit simulation for both the candidate and production models. The promotion criteria should require the candidate to have both a lower or equal MAE and a higher simulated profit margin.
    3. C.Replace MAE with simulated profit margin as the sole metric for model selection by running the simulation on every candidate model and promoting the one with the highest margin. The simulation uses a holdout set of recent transactions to estimate the profit impact.
    4. D.Manually run the profit simulation outside the automated workflow for each candidate model, then submit the results to the business team for approval before any model promotion occurs. This process involves extracting the candidate model's predictions.
    Show answer & explanation

    Correct answer: BAdd a step in the retraining workflow that runs the profit simulation for both the candidate and production models. The promotion criteria should require the candidate to have both a lower or equal MAE and a higher simulated profit margin.

    • A. Incorrect. This approach fails to integrate the business-critical metric into the automated decision-making process. It keeps the evaluation separate and manual, which introduces delays, negates the benefits of a fully automated MLOps pipeline, and prevents the system from automatically selecting models that are truly better for the business.
    • B. Correct. This is the optimal approach as it integrates the business-centric metric directly into the automated promotion workflow without discarding the standard technical metric. By using a multi-faceted promotion criterion (non-degrading technical performance via MAE and improved business performance via simulated profit), it creates a robust system that ensures deployed models are both technically sound and aligned with core business objectives, which is a hallmark of a mature MLOps practice.
    • C. Incorrect. Relying solely on a simulated business metric is risky. Simulations are estimations and can be noisy or have limitations. A model might find a way to 'game' the simulation to show high profit while having poor predictive accuracy. Maintaining a technical metric like MAE acts as a crucial guardrail, ensuring the model's fundamental performance remains stable and preventing potential degradation that might be hidden by focusing only on the simulated outcome.
    • D. Incorrect. This option is the antithesis of MLOps automation. Introducing manual steps and approvals outside the workflow creates significant bottlenecks, slows down the model iteration and deployment cycle, and increases the risk of human error. The primary goal of MLOps is to streamline and automate this process, and this approach reverses that progress.

    2.4 Automated Retraining

    25.A model serving a latency-sensitive application (sub-100ms response time) requires frequent retraining. The full retraining process takes 2 hours to complete. The automated system must deploy the newly trained model without adding any significant latency to the existing prediction endpoint during the update. Which approach is most suitable?

    1. A.Trigger the retraining job directly from the model serving endpoint whenever a prediction is slow, using the endpoint's own compute to initiate a full 2-hour retraining pipeline that replaces the model artifact in place without a separate deployment step.
    2. B.Use a serverless model serving endpoint that supports zero-downtime updates, where the platform handles the traffic shifting from the old model version to the new one seamlessly in the background after the new version is ready.
    3. C.Run an `UPDATE` command on the model serving endpoint configuration to swap the model artifact, relying on the platform's built-in blocking reload that pauses inference requests for a few seconds while the new model is loaded into memory.
    4. D.The retraining job should write the new model artifact to DBFS, and the serving endpoint should be programmed to check for a new model file every 100ms and load it if found, using a polling loop that adds negligible overhead to each prediction request.
    Show answer & explanation

    Correct answer: BUse a serverless model serving endpoint that supports zero-downtime updates, where the platform handles the traffic shifting from the old model version to the new one seamlessly in the background after the new version is ready.

    • A. Incorrect. Triggering a 2-hour retraining job directly from the serving endpoint based on prediction latency tightly couples serving and training, which is a poor design pattern. It does not provide a zero-downtime deployment mechanism and would likely disrupt the endpoint's ability to meet sub-100ms response times.
    • B. Correct. A serverless model serving endpoint with zero-downtime updates implements a blue-green deployment strategy, where the platform seamlessly shifts traffic from the old model version to the new one after it is ready. This approach ensures no significant latency is added to the prediction endpoint during the update, meeting the strict sub-100ms requirement.
    • C. Incorrect. Using an `UPDATE` command that causes a blocking reload pauses inference requests for a few seconds, which constitutes significant latency. This violates the requirement to avoid adding any significant latency to a latency-sensitive application with sub-100ms response times.
    • D. Incorrect. A polling loop that checks for a new model file every 100ms adds overhead to each prediction request and can cause latency spikes during model loading. This manual approach is inefficient and fails to guarantee the sub-100ms response time, making it unsuitable for a latency-sensitive application.

    2.3 Environment Architectures

    26.In a Databricks Asset Bundle, what is the purpose of defining an `mlflow_experiment` resource?

    1. A.To run a new MLflow tracking experiment as a job, defining the experiment's name and artifact location within the bundle for automated execution.
    2. B.To create a new, empty model in the MLflow Model Registry, defining its name and initial tags to prepare a location for versioned model artifacts.
    3. C.To declaratively create and manage an MLflow Experiment in the workspace, ensuring a consistent location for logging runs.
    4. D.To serve a model from an MLflow experiment as a real-time endpoint, defining the endpoint's name, model URI, and required compute resources.
    Show answer & explanation

    Correct answer: CTo declaratively create and manage an MLflow Experiment in the workspace, ensuring a consistent location for logging runs.

    • A. Incorrect. This option confuses the declarative definition of a resource with the execution of a job. The `mlflow_experiment` resource ensures the experiment exists, while a `job` resource would be used to define and run the code that logs to that experiment.
    • B. Incorrect. This confuses an MLflow Experiment with the MLflow Model Registry. An experiment is a container for logging runs and their associated metrics, parameters, and artifacts. The Model Registry is a separate system for managing, versioning, and staging trained model artifacts.
    • C. Correct. The primary purpose of an `mlflow_experiment` resource in a Databricks Asset Bundle is to declaratively define and manage an MLflow Experiment. This Infrastructure-as-Code approach ensures that a consistent, predictable location exists in the workspace for logging all ML runs related to the project, which is fundamental for reproducibility and collaboration.
    • D. Incorrect. MLflow experiments, which are collections of run metadata, are not served as endpoints. Real-time serving endpoints are for deploying trained MLflow models. This is typically managed via a `serving_endpoint` resource in a bundle, not an `mlflow_experiment` resource.

    2.2 Validation Testing

    27.An MLOps team is designing an integration test for a pipeline where a feature engineering job writes to a Delta table, and a downstream training job reads from it. The test needs to ensure data contract compliance between the two jobs. What is the most robust way to test this specific interaction?

    1. A.Manually run the feature engineering job on a golden dataset, then visually inspect the Delta table schema in the UI to confirm column names and types match the training job's expectations before initiating the downstream training process.
    2. B.The test should first execute the feature engineering job on a golden dataset, then run the training job, and finally verify that the training job completes successfully without schema-related errors.
    3. C.Assume the schemas are correct as long as both jobs are in the same Databricks Repo and the feature engineering job writes to a Delta table that the training job reads, relying on the repo's shared environment to enforce consistency.
    4. D.Unit test the feature engineering function against a mocked input to verify its output DataFrame's structure, and separately, unit test the training function by providing a mocked input DataFrame that matches its expected schema.
    Show answer & explanation

    Correct answer: BThe test should first execute the feature engineering job on a golden dataset, then run the training job, and finally verify that the training job completes successfully without schema-related errors.

    • A. Incorrect. Manually running the job and visually inspecting the schema is error-prone and not scalable. A robust integration test must be automated to reliably validate the data contract in a CI/CD pipeline.
    • B. Correct. This approach executes the feature engineering job on a golden dataset, then runs the training job, and verifies successful completion without schema errors. It directly validates the data contract between the two jobs in an automated, repeatable manner.
    • C. Incorrect. Placing both jobs in the same Databricks Repo does not enforce schema consistency. The jobs can evolve independently, and only an actual integration test can catch schema mismatches.
    • D. Incorrect. Unit testing each function in isolation with mocked inputs does not test the interaction between the feature engineering and training jobs. An integration test is needed to verify that the actual output of one component meets the input requirements of the other.

    2.3 Environment Architectures

    28.A team is adopting Databricks Asset Bundles (DABs) to manage their ML projects. They have a project structure with a `src` directory containing Python source code and a `notebooks` directory. In their `databricks.yml`, they define a job that runs a notebook. How should they ensure their Python source code in the `src` directory is available as a library to the job's notebook task?

    1. A.Manually build a Python wheel from the `src` directory using a build command, upload the resulting file to DBFS, and then reference its path within the job's `libraries` configuration.
    2. B.Add a `sync` block to the `databricks.yml` file to copy the `src` directory's contents to a workspace path, making the source files available to the job's notebook task.
    3. C.Use a `%pip install` magic command in the first cell of the notebook task to install the library directly from the project's Git repository URL, making the `src` code available.
    4. D.Include a `build` section in the `databricks.yml` that specifies `wheel` as the build driver, and the bundle will automatically build and deploy the wheel for job tasks.
    Show answer & explanation

    Correct answer: DInclude a `build` section in the `databricks.yml` that specifies `wheel` as the build driver, and the bundle will automatically build and deploy the wheel for job tasks.

    • A. Incorrect. This manual approach undermines the automation and reproducibility benefits of Databricks Asset Bundles. It requires extra steps to build and upload the wheel to DBFS, and then reference it in the job configuration, which is not the recommended DAB workflow.
    • B. Incorrect. The `sync` block copies files to the workspace but does not install them as a library or add them to the Python path. The notebook would need manual path manipulation to import the code, which is not a robust or standard practice for DABs.
    • C. Incorrect. Installing directly from a Git repository bypasses DAB packaging and versioning, introducing runtime dependencies and potential reproducibility issues. The code executed should be the version packaged with the bundle, not fetched at runtime.
    • D. Correct. This is the recommended DAB approach: a `build` section with the `wheel` driver automatically builds a Python wheel from the `src` directory during `databricks bundle deploy`. The wheel is uploaded and configured as a library for job tasks, making the source code importable without manual steps.

    Domain 3: Model Deployment

    3.1 Deployment Strategies

    29.Which of the following scenarios is the WORST fit for a canary deployment strategy?

    1. A.Deploying a model where a single incorrect prediction could have catastrophic financial consequences.
    2. B.Rolling out a new feature to a subset of users to gather feedback.
    3. C.Testing the performance of a new model version under a small amount of production load.
    4. D.Deploying a minor bug fix to a data preprocessing pipeline.
    Show answer & explanation

    Correct answer: ADeploying a model where a single incorrect prediction could have catastrophic financial consequences.

    • A. Correct. A canary deployment's purpose is to mitigate risk by exposing only a small subset of production traffic to a new model version. However, it does not eliminate risk. In scenarios where a single incorrect prediction can have catastrophic consequences (e.g., high-frequency trading, critical medical diagnostics), any exposure to live traffic is unacceptable. Such high-stakes models require more rigorous pre-deployment validation, such as extensive offline simulation or shadow deployments, before any live user traffic is served.
    • B. Incorrect. This is an ideal use case for a canary deployment. Gradually rolling out a new feature to a small, controlled group of users allows the team to gather valuable feedback, monitor user engagement, and identify issues before a full-scale launch, minimizing the potential negative impact.
    • C. Incorrect. This is a classic and highly suitable application for a canary deployment. By routing a small percentage of production load to the new model version, engineers can compare its performance (e.g., latency, CPU/memory usage, error rates) against the stable version under real-world conditions with minimal risk to the overall service.
    • D. Incorrect. A canary deployment is a suitable strategy for this scenario. Deploying a bug fix, even a minor one, to a small portion of the data processing workload first allows for verification that the fix works as intended and does not introduce any unintended side effects or downstream data quality issues before it is rolled out completely.

    3.1 Deployment Strategies

    30.A data science team wants to test three new experimental models (A, B, C) against the current production model (Control). They want to dynamically and automatically allocate more traffic to the models that are performing better on a key business metric (e.g., click-through rate). This advanced strategy is known as:

    1. A.Multi-canary deployment
    2. B.Cascading blue-green deployment
    3. C.Multi-armed bandit
    4. D.Shadow A/B testing
    Show answer & explanation

    Correct answer: CMulti-armed bandit

    • A. Incorrect. Multi-canary deployment involves incrementally rolling out new model versions to small, predefined subsets of users to mitigate risk. While multiple versions can be deployed, traffic is typically allocated based on a fixed schedule (e.g., 1%, 5%, 20%) rather than being dynamically and automatically adjusted based on real-time performance metrics.
    • B. Incorrect. Blue-green deployment involves switching traffic between two identical environments (blue and green). This strategy is for managing releases with minimal downtime and easy rollback, not for dynamically routing traffic among multiple competing models based on performance.
    • C. Correct. Multi-armed bandit is a reinforcement learning-based strategy where multiple models (the 'arms') are tested simultaneously in production. It dynamically allocates traffic to the models based on their real-time performance on a key metric (the 'reward'), effectively balancing exploration (testing new models) and exploitation (using the best-performing model) to maximize the overall business outcome.
    • D. Incorrect. Shadow A/B testing, or shadow deployment, involves running a new model in parallel with the production model, using a copy of the live traffic. However, the new model's predictions are not shown to users and do not impact their experience. The goal is to evaluate the new model's performance and stability under real-world conditions for offline analysis before a live deployment.

    3.1 Deployment Strategies

    31.Which deployment strategy's name is a metaphor derived from the historical practice of using canaries in coal mines to detect toxic gases?

    1. A.Blue-green deployment
    2. B.Shadow deployment
    3. C.A/B testing
    4. D.Canary deployment
    Show answer & explanation

    Correct answer: DCanary deployment

    • A. Incorrect. Blue-green deployment is a strategy that involves running two identical production environments (blue and green). The new version is deployed to the idle environment (green), and once it's verified, traffic is switched over from the live environment (blue). The name is not related to the canary metaphor.
    • B. Incorrect. Shadow deployment involves running a new version of a model in parallel with the current production version. It receives a copy of the live traffic, allowing for performance testing under real-world load without impacting users, as its predictions are not served. The term 'shadow' is unrelated to canaries in coal mines.
    • C. Incorrect. A/B testing is an experimentation method used to compare two or more versions of a model by splitting user traffic between them. Its primary goal is to determine which version performs better on key business metrics. The name has no connection to the historical practice with canaries.
    • D. Correct. This deployment strategy is named after the historical practice of sending canaries into coal mines to act as an early warning system for toxic gases. Similarly, a canary deployment releases a new version to a small subset of users to detect potential issues and monitor performance before rolling it out to the entire user base, thus minimizing risk.

    3.2 Custom Model Serving

    32.Which class from the `mlflow.deployments` SDK is used to create, update, and query model serving endpoints on Databricks?

    1. A.`mlflow.tracking.MlflowClient`
    2. B.`databricks.sdk.service.serving.ServingEndpointsAPI`
    3. C.`mlflow.deployments.DatabricksDeploymentClient`
    4. D.`mlflow.projects.DatabricksProject`
    Show answer & explanation

    Correct answer: C`mlflow.deployments.DatabricksDeploymentClient`

    • A. Incorrect. The `mlflow.tracking.MlflowClient` is the primary programmatic interface for the MLflow Tracking component. It is used for managing experiments, runs, and logging parameters, metrics, and artifacts, not for managing model serving endpoints.
    • B. Incorrect. While `databricks.sdk.service.serving.ServingEndpointsAPI` is used for managing serving endpoints, it is part of the Databricks SDK, not the `mlflow.deployments` SDK as specified in the question.
    • C. Correct. `mlflow.deployments.DatabricksDeploymentClient` is the specific class within the `mlflow.deployments` SDK designed to programmatically create, update, and query model serving endpoints on the Databricks platform.
    • D. Incorrect. The `mlflow.projects` module is used for packaging code into a reusable and reproducible format. It allows you to run MLflow projects on Databricks, but it is not used for creating or managing real-time model serving endpoints.

    3.1 Deployment Strategies

    33.Your team has successfully completed a blue-green deployment, and the new version is stable. What is the best practice for handling the old, now idle 'blue' environment to manage costs and prepare for the next deployment cycle?

    1. A.Keep it running indefinitely as a hot-standby to absorb traffic instantly if the new version fails, maintaining full capacity without any cutover delay.
    2. B.Immediately delete all resources, such as compute instances and load balancers, to eliminate ongoing charges, assuming the new environment will remain stable.
    3. C.Keep it running for a defined period (e.g., 24 hours) to ensure no rollback is needed, then decommission it or use it to stage the next release.
    4. D.Reroute 1% of traffic back to it for continuous monitoring of performance and errors, using the old stack as a canary to detect regressions before they affect all users.
    Show answer & explanation

    Correct answer: CKeep it running for a defined period (e.g., 24 hours) to ensure no rollback is needed, then decommission it or use it to stage the next release.

    • A. Incorrect. Keeping the old environment running indefinitely as a hot-standby is not cost-effective, as it incurs ongoing charges for idle resources. Once the new version is stable, the old environment should be decommissioned or repurposed to avoid unnecessary costs.
    • B. Incorrect. Immediately deleting all resources eliminates the ability to perform a rapid rollback if issues are discovered later. A key benefit of blue-green deployment is maintaining the old environment for a buffer period to ensure the new version is truly stable before cleanup.
    • C. Correct. This approach balances safety and cost by keeping the old environment available for a defined observation period, allowing a quick rollback if needed. After confirming stability, decommissioning it saves costs, and repurposing it to stage the next release streamlines the deployment cycle.
    • D. Incorrect. Rerouting a small percentage of traffic back to the old environment describes a canary release or A/B testing pattern, not a blue-green deployment. In blue-green, traffic is fully switched to the new version once validated, and the old environment is no longer used for production traffic.

    3.2 Custom Model Serving

    34.A team is evaluating two candidate models for a production serving endpoint and wants to route 10% of the traffic to the new challenger model and 90% to the existing champion model. How is this traffic split configured when using the REST API or MLflow Deployments SDK?

    1. A.By creating two separate endpoints for the champion and challenger models and configuring a client-side load balancer to route 90% of requests to the champion endpoint and 10% to the challenger endpoint.
    2. B.Within the `config` object of the endpoint definition, by defining two entries in the `served_models` array, each with its `model_uri` and a specified `traffic_percentage`.
    3. C.By setting environment variables `CHAMPION_TRAFFIC` and `CHALLENGER_TRAFFIC` on the endpoint to the values 90 and 10, which the serving infrastructure reads to allocate traffic between the two models.
    4. D.By implementing custom logic within the `pyfunc` model's `predict` method to inspect a random number and route the request to either the champion or challenger model based on the desired 90/10 split.
    Show answer & explanation

    Correct answer: BWithin the `config` object of the endpoint definition, by defining two entries in the `served_models` array, each with its `model_uri` and a specified `traffic_percentage`.

    • A. Incorrect. Creating two separate endpoints and configuring a client-side load balancer is overly complex and error-prone. Databricks Model Serving provides built-in traffic splitting that eliminates the need for external routing infrastructure.
    • B. Correct. This is the standard method for traffic splitting. The endpoint's `config` object contains a `served_models` array where each entry specifies a `model_uri` and a `traffic_percentage`. The percentages across all entries must sum to 100.
    • C. Incorrect. Databricks Model Serving does not use environment variables to configure traffic routing. Traffic splits are managed directly within the endpoint's configuration via the REST API or MLflow Deployments SDK.
    • D. Incorrect. Embedding routing logic in the `predict` method violates separation of concerns and adds unnecessary complexity. The serving infrastructure should handle traffic routing, not the model artifact itself.

    3.2 Custom Model Serving

    35.When an external application, such as a web service running outside of Databricks, needs to send requests to a Databricks Model Serving endpoint, what is the standard method for authentication?

    1. A.A Databricks Personal Access Token (PAT) or a service principal token included as a Bearer token in the `Authorization` header.
    2. B.Basic authentication encodes a Databricks username and password in the HTTP Authorization header for every request to the Model Serving endpoint.
    3. C.An OAuth 2.0 client credentials flow where the external application obtains a token from Databricks and presents it to the endpoint.
    4. D.The IP address of the external application must be added to an allowlist in the endpoint configuration to authorize requests.
    Show answer & explanation

    Correct answer: AA Databricks Personal Access Token (PAT) or a service principal token included as a Bearer token in the `Authorization` header.

    • A. Correct. The standard and secure method for authenticating requests from external applications to Databricks Model Serving endpoints is to use a token. This can be a Personal Access Token (PAT) associated with a user or a token generated for a service principal. The token must be included in the `Authorization` header of the HTTP request with the 'Bearer' scheme (e.g., `Authorization: Bearer <your-token>`).
    • B. Incorrect. Basic authentication using a username and password is not a supported or recommended method for Databricks Model Serving endpoints. Token-based authentication is the required approach as it is more secure and designed for programmatic API access.
    • C. Incorrect. While OAuth 2.0 client credentials flow is a common authentication framework for many web services, Databricks Model Serving endpoints do not use this flow for service-to-service communication. Authentication relies on pre-generated, long-lived tokens like PATs or service principal tokens.
    • D. Incorrect. IP allowlisting is a network security control, not an authentication method. It restricts access to the endpoint from only approved IP addresses, providing an additional layer of security (authorization). However, it does not verify the identity of the calling application. The primary authentication mechanism is still required, which is token-based.

    Want the full experience?

    These are just samples. Practice the full Databricks Certified Machine Learning Professional question bank in quiz mode — free, no signup, with domain practice and exam simulation.