2 packs: 15% off with code BUY2. 3 or more: 20% off with code BUY3.

Free Databricks Machine Learning Associate Practice Questions

31 free Databricks Machine Learning Associate practice questions from the CertStash pack of 140, each with the correct answer and a full explanation. The rule is the same for every exam: ten free on the product page, 31 free here, all 140 in the pack, and each step includes the one before it.

Question 1

A data scientist is using MLflow to track their machine learning experiment. As a part of each of their MLflow runs, they are performing hyperparameter tuning. The data scientist would like to have one parent run for the tuning process with a child run for each unique combination of hyperparameter values. All parent and child runs are being manually started with mlflow.start_run. Which of the following approaches can the data scientist use to accomplish this MLflow run organization?

  1. They can turn on Databricks Autologging
  2. They can specify nested=True when starting the child run for each unique combination of hyperparameter values
  3. They can start each child run inside the parent run's indented code block using mlflow.start_run()
  4. They can start each child run with the same experiment ID as the parent run
  5. They can specify nested=True when starting the parent run for the tuning process
Show answer and explanation

Correct answer: B. They can specify nested=True when starting the child run for each unique combination of hyperparameter values

MLflow supports hierarchical run organization through nested runs. When starting a child run, passing nested=True parameter creates a parent-child relationship between the currently active run and the new run being started. This allows a data scientist to have one parent run tracking the overall tuning process with multiple child runs, each representing a unique hyperparameter combination. The nested=True parameter must be specified on the child run calls, not the parent.

Why the other options are wrong

  • A. Databricks Autologging automatically logs metrics and parameters but does not create parent-child run hierarchies.
  • C. Simply nesting code blocks does not establish a parent-child relationship in MLflow without the nested=True parameter.
  • D. Using the same experiment ID does not create parent-child relationships; runs would be independent siblings in the same experiment.
  • E. The nested=True parameter on the parent run is incorrect syntax; it must be specified when starting child runs.

Question 2

Which of the following approaches can be used to view the notebook that was run to create an MLflow run?

  1. Open the MLmodel artifact in the MLflow run page
  2. Click the “Models” link in the row corresponding to the run in the MLflow experiment page
  3. Click the “Source” link in the row corresponding to the run in the MLflow experiment page
  4. Click the “Start Time” link in the row corresponding to the run in the MLflow experiment page
Show answer and explanation

Correct answer: C. Click the “Source” link in the row corresponding to the run in the MLflow experiment page

MLflow automatically tracks the source notebook that created a run when executed in Databricks. The MLflow experiment page displays a clickable 'Source' link in each run's row that directs to the notebook that was executed to generate that run. This provides direct access to view the notebook code and understand the experiment's origin.

Why the other options are wrong

  • A. The MLmodel artifact contains model serialization information, not notebook source code.
  • B. The 'Models' link navigates to registered models or model artifacts, not the source notebook.
  • D. The 'Start Time' link displays timestamp information for the run, not notebook source code.

Question 3

A data scientist is developing a machine learning pipeline using AutoML on Databricks Machine Learning. Which of the following steps will the data scientist need to perform outside of their AutoML experiment?

  1. Model tuning
  2. Model evaluation
  3. Model deployment
  4. Exploratory data analysis
Show answer and explanation

Correct answer: C. Model deployment

Databricks AutoML handles hyperparameter tuning, model selection, and evaluation automatically within the AutoML experiment process. It trains multiple models and identifies the best performer with detailed metrics. However, model deployment, moving the trained model into production and setting up serving infrastructure, occurs outside the AutoML experiment and requires separate steps for model registry, endpoint creation, and configuration.

Why the other options are wrong

  • A. Model tuning is a core AutoML function; the system performs extensive hyperparameter search and optimization.
  • B. Model evaluation is performed by AutoML; it automatically evaluates candidate models and ranks them.
  • D. Exploratory data analysis can be performed within AutoML experiments; the system handles data analysis as part of the process.

Question 4

A machine learning engineer has grown tired of needing to install the MLflow Python library on each of their clusters. They ask a senior machine learning engineer how their notebooks can load the MLflow library without installing it each time. The senior machine learning engineer suggests that they use Databricks Runtime for Machine Learning. Which of the following approaches describes how the machine learning engineer can begin using Databricks Runtime for Machine Learning?

  1. They can add a line enabling Databricks Runtime ML in their init script when creating their clusters.
  2. They can check the Databricks Runtime ML box when creating their clusters.
  3. They can select a Databricks Runtime ML version from the Databricks Runtime Version dropdown when creating their clusters.
  4. They can set the runtime-version variable in their Spark session to “ml”.
Show answer and explanation

Correct answer: C. They can select a Databricks Runtime ML version from the Databricks Runtime Version dropdown when creating their clusters.

Databricks Runtime for Machine Learning is selected when creating a cluster by choosing a Databricks Runtime ML version from the Databricks Runtime Version dropdown menu. The dropdown displays available runtimes, which include standard Databricks Runtime versions and Databricks Runtime for Machine Learning versions that come pre-installed with MLflow, scikit-learn, and other ML libraries. This eliminates the need to manually install these libraries on each cluster.

Why the other options are wrong

  • A. Init scripts cannot enable Databricks Runtime ML; the runtime is a cluster-level configuration selected during cluster creation.
  • B. There is no 'Databricks Runtime ML checkbox' in the cluster creation interface; selection is made through the runtime version dropdown.
  • D. The runtime-version variable in Spark session configuration does not control which Databricks Runtime is used; runtime selection occurs at cluster creation time.

Question 5

A data scientist uses 3-fold cross-validation when optimizing model hyperparameters for a regression problem. The following root-mean-squarederror values are calculated on each of the validation folds: • 10.0 • 12.0 • 17.0 Which of the following values represents the overall cross-validation root-mean-squared error?

  1. 13.0
  2. 17.0
  3. 12.0
  4. 39.0
  5. 10.0
Show answer and explanation

Correct answer: A. 13.0

In k-fold cross-validation, the overall cross-validation score is calculated as the mean of the validation scores across all folds. With RMSE values of 10.0, 12.0, and 17.0, the mean is (10.0 + 12.0 + 17.0) / 3 = 39.0 / 3 = 13.0. This aggregated metric represents the model's expected performance across the entire dataset.

Why the other options are wrong

  • B. 17.0 is the maximum error from a single fold, not the overall cross-validation metric.
  • C. 12.0 is one individual fold's error, not the aggregation of all folds.
  • D. 39.0 is the sum of all errors, not the mean required for cross-validation reporting.
  • E. 10.0 is the minimum error from a single fold, not the overall cross-validation metric.

Question 6

What is the name of the method that transforms categorical features into a series of binary indicator feature variables?

  1. Leave-one-out encoding
  2. Target encoding
  3. One-hot encoding
  4. Categorical embeddings
  5. String indexing
Show answer and explanation

Correct answer: C. One-hot encoding

One-hot encoding is the standard method that converts categorical variables into a series of binary indicator variables, with each category represented by a separate binary column containing 0 or 1. This approach is widely used in machine learning to handle categorical data for algorithms that require numerical input.

Why the other options are wrong

  • A. Leave-one-out encoding is a cross-validation technique, not a categorical feature transformation method.
  • B. Target encoding replaces categorical values with the mean target value for that category, not binary indicators.
  • D. Categorical embeddings map categories to continuous vector representations, not binary indicators.
  • E. String indexing converts categorical strings to numerical indices sequentially, not into multiple binary columns.

Question 7

A data scientist wants to parallelize the training of trees in a gradient boosted tree to speed up the training process. A colleague suggests that parallelizing a boosted tree algorithm can be difficult. Which of the following describes why?

  1. Gradient boosting is not a linear algebra-based algorithm which is required for parallelization.
  2. Gradient boosting requires access to all data at once which cannot happen during parallelization.
  3. Gradient boosting calculates gradients in evaluation metrics using all cores which prevents parallelization.
  4. Gradient boosting is an iterative algorithm that requires information from the previous iteration to perform the next step.
  5. Gradient boosting uses decision trees in each iteration which cannot be parallelized.
Show answer and explanation

Correct answer: D. Gradient boosting is an iterative algorithm that requires information from the previous iteration to perform the next step.

Gradient boosting is inherently sequential because each new tree must be trained on the residuals from the previous iteration. The algorithm requires the results and gradients from the prior step to calculate the next step, making the trees dependent on their predecessors. This sequential dependency prevents effective parallelization across iterations, though individual tree splits can sometimes be parallelized.

Why the other options are wrong

  • A. Gradient boosting involves linear algebra operations and mathematical computations that can be parallelized in principle.
  • B. While gradient boosting needs access to data, this data can be distributed across nodes during parallelization.
  • C. Gradient boosting calculations do not inherently require all cores for gradient evaluation in ways that prevent parallelization.
  • E. Decision trees themselves can be parallelized by splitting the search for optimal split points across multiple cores.

Question 8

Which of the following tools can be used to parallelize the hyperparameter tuning process for single-node machine learning models using a Spark cluster?

  1. MLflow Experiment Tracking
  2. Spark ML
  3. Autoscaling clusters
  4. Hyperopt
  5. Delta Lake
Show answer and explanation

Correct answer: D. Hyperopt

Hyperopt is a tool specifically designed to parallelize hyperparameter optimization across distributed computing environments, including Spark clusters. It uses algorithms like Tree-structured Parzen Estimators to efficiently search the hyperparameter space and can distribute the tuning process across multiple nodes to speed up model optimization.

Why the other options are wrong

  • A. MLflow Experiment Tracking is used for logging and comparing experiment metrics, not for parallelizing hyperparameter tuning.
  • B. Spark ML provides distributed machine learning pipelines but is not specifically designed for hyperparameter tuning parallelization.
  • C. Autoscaling clusters adjust compute resources but do not actively parallelize the hyperparameter tuning process itself.
  • E. Delta Lake is a storage format for managing data reliability and governance, not a hyperparameter tuning tool.

Question 9

Which of the following describes the relationship between native Spark DataFrames and pandas API on Spark DataFrames?

  1. pandas API on Spark DataFrames are single-node versions of Spark DataFrames with additional metadata
  2. pandas API on Spark DataFrames are more performant than Spark DataFrames
  3. pandas API on Spark DataFrames are made up of Spark DataFrames and additional metadata
  4. pandas API on Spark DataFrames are less mutable versions of Spark DataFrames
  5. pandas API on Spark DataFrames are unrelated to Spark DataFrames
Show answer and explanation

Correct answer: C. pandas API on Spark DataFrames are made up of Spark DataFrames and additional metadata

The pandas API on Spark is built as a wrapper around native Spark DataFrames, maintaining all the distributed computing capabilities of Spark while providing a pandas-like interface. It consists of Spark DataFrames internally plus additional metadata that maps pandas API calls to equivalent Spark operations, allowing users to write pandas-style code that executes on Spark.

Why the other options are wrong

  • A. pandas API on Spark DataFrames are distributed, not single-node versions, and maintain Spark's distributed nature.
  • B. pandas API on Spark DataFrames have comparable performance to Spark DataFrames since they execute on the same Spark engine.
  • D. pandas API on Spark DataFrames are equally mutable as native Spark DataFrames.
  • E. pandas API on Spark DataFrames are directly related to and built upon Spark DataFrames.

Question 10

A data scientist has written a data cleaning notebook that utilizes the pandas library, but their colleague has suggested that they refactor their notebook to scale with big data. Which of the following approaches can the data scientist take to spend the least amount of time refactoring their notebook to scale with big data?

  1. They can refactor their notebook to process the data in parallel.
  2. They can refactor their notebook to use the PySpark DataFrame API.
  3. They can refactor their notebook to use the Scala Dataset API.
  4. They can refactor their notebook to use Spark SQL.
  5. They can refactor their notebook to utilize the pandas API on Spark.
Show answer and explanation

Correct answer: E. They can refactor their notebook to utilize the pandas API on Spark.

The pandas API on Spark allows data scientists to use familiar pandas syntax with minimal code changes while automatically leveraging Spark's distributed computing. Since the API mirrors pandas methods and operations, refactoring a pandas notebook to use this interface requires the least amount of code rewriting compared to learning PySpark, Scala, or Spark SQL syntax entirely.

Why the other options are wrong

  • A. Manual parallel processing refactoring is more complex than using a dedicated API.
  • B. The PySpark DataFrame API requires learning new syntax and methods different from pandas.
  • C. Using Scala requires learning an entirely new programming language.
  • D. Spark SQL requires rewriting logic in SQL syntax, which differs significantly from pandas operations.

Question 11

A data scientist has a Spark DataFrame spark_df. They want to create a new Spark DataFrame that contains only the rows from spark_df where the value in column discount is less than or equal 0. Which of the following code blocks will accomplish this task?

  1. spark_df.loc[:,spark_df["discount"] <= 0]
  2. spark_df[spark_df["discount"] <= 0]
  3. spark_df.filter (col("discount") <= 0)
  4. spark_df.loc(spark_df["discount"] <= 0, :]
Show answer and explanation

Correct answer: C. spark_df.filter (col("discount") <= 0)

Spark DataFrames use the filter() method with Spark SQL Column objects created via col() to apply boolean conditions. This syntax correctly filters rows where the discount column is less than or equal to 0, returning a new DataFrame containing only matching rows.

Why the other options are wrong

  • A. The .loc syntax is pandas-specific and not available in Spark DataFrames.
  • B. Direct bracket indexing with boolean conditions is also pandas syntax and does not work with Spark DataFrames.
  • D. The .loc() method with this syntax is neither valid pandas nor Spark syntax; Spark DataFrames do not support .loc().

Question 12

A new data scientist has started working on an existing machine learning project. The project is a scheduled Job that retrains every day. The project currently exists in a Repo in Databricks. The data scientist has been tasked with improving the feature engineering of the pipeline’s preprocessing stage. The data scientist wants to make necessary updates to the code that can be easily adopted into the project without changing what is being run each day. Which approach should the data scientist take to complete this task?

  1. They can create a new branch in Databricks, commit their changes, and push those changes to the Git provider.
  2. They can clone the notebooks in the repository into a Databricks Workspace folder and make the necessary changes.
  3. They can create a new Git repository, import it into Databricks, and copy and paste the existing code from the original repository before making changes.
  4. They can clone the notebooks in the repository into a new Databricks Repo and make the necessary changes.
Show answer and explanation

Correct answer: A. They can create a new branch in Databricks, commit their changes, and push those changes to the Git provider.

Creating a new branch in Databricks, committing changes, and pushing them to the Git provider follows standard Git workflow practices and allows the data scientist to make updates that can be easily reviewed, tested, and merged into the main branch without disrupting the scheduled job. This approach maintains version control, enables collaboration, and allows changes to be adopted into production through proper code review. Option B creates local copies outside version control. Option C unnecessarily duplicates the repository. Option D creates a redundant repo instead of using branches for feature work.

Why the other options are wrong

  • B. Cloning notebooks into a Workspace folder bypasses version control and makes it difficult to merge changes back into the project tracked by the Job.
  • C. Creating a new Git repository duplicates work unnecessarily and complicates the process of integrating improvements back into the original project.
  • D. Creating a new Repo instead of using branches on the existing Repo creates unnecessary duplication and does not follow standard Git workflow practices for feature development.

Question 13

Which of the following hyperparameter optimization methods automatically makes informed selections of hyperparameter values based on previous trials for each iterative model evaluation?

  1. Random Search
  2. Halving Random Search
  3. Tree of Parzen Estimators
  4. Grid Search
Show answer and explanation

Correct answer: C. Tree of Parzen Estimators

Tree of Parzen Estimators (TPE) is a Bayesian optimization method that builds probabilistic models of the objective function based on previous trials. It uses these models to make informed decisions about which hyperparameter values to evaluate next, focusing the search on promising regions of the hyperparameter space. This sequential, informed approach contrasts with methods that select values randomly or exhaustively.

Why the other options are wrong

  • A. Random Search selects hyperparameter values randomly without leveraging information from previous trials.
  • B. Halving Random Search uses random selection with early stopping; it does not make informed selections based on previous trial results.
  • D. Grid Search exhaustively tests all combinations without learning from previous evaluations or adapting selections.

Question 14

A data scientist has replaced missing values in their feature set with each respective feature variable’s median value. A colleague suggests that the data scientist is throwing away valuable information by doing this. Which of the following approaches can they take to include as much information as possible in the feature set?

  1. Impute the missing values using each respective feature variable’s mean value instead of the median value
  2. Refrain from imputing the missing values in favor of letting the machine learning algorithm determine how to handle them
  3. Remove all feature variables that originally contained missing values from the feature set
  4. Create a binary feature variable for each feature that contained missing values indicating whether each row’s value has been imputed
  5. Create a constant feature variable for each feature that contained missing values indicating the percentage of rows from the feature that was originally missing
Show answer and explanation

Correct answer: D. Create a binary feature variable for each feature that contained missing values indicating whether each row’s value has been imputed

Creating binary indicator variables for each feature that contained missing values preserves information about which rows had imputed values versus original values. This allows the model to learn whether missingness itself is predictive, which is valuable information that simple imputation discards. Option A only changes the imputation method, not the information preserved. Option B leaves data incomplete. Option C removes features entirely. Option E creates a constant feature that provides less granular information than row-level indicators.

Why the other options are wrong

  • A. Switching from median to mean imputation does not preserve information about which values were imputed.
  • B. Most machine learning algorithms require complete feature values and cannot effectively handle missing data directly.
  • C. Removing features entirely discards all information from those variables, which is wasteful.
  • E. A constant feature for percentage missing provides less information than binary indicators showing which specific rows were imputed.

Question 15

Which of the following evaluation metrics is not suitable to evaluate runs in AutoML experiments for regression problems?

  1. F1
  2. R-squared
  3. MAE
  4. MSE
Show answer and explanation

Correct answer: A. F1

F1 is not suitable for evaluating regression problems; it is a classification metric used to measure the balance between precision and recall. R-squared (B) measures the proportion of variance explained by the model, MAE (C) measures mean absolute error, and MSE (D) measures mean squared error, all appropriate for regression. AutoML for regression uses metrics designed for continuous target variables, not the binary classification focus of F1.

Why the other options are wrong

  • B. R-squared is a standard regression metric that measures how well the model explains variance in the target variable.
  • C. MAE (Mean Absolute Error) is an appropriate regression evaluation metric measuring average absolute differences between predicted and actual values.
  • D. MSE (Mean Squared Error) is a standard regression metric that penalizes larger errors and is commonly used in AutoML regression experiments.

Question 16

A data scientist is using Spark ML to engineer features for an exploratory machine learning project. They decide they want to standardize their features using the following code block: Upon code review, a colleague expressed concern with the features being standardized prior to splitting the data into a training set and a test set. Which of the following changes can the data scientist make to address the concern?

  1. Utilize the MinMaxScaler object to standardize the training data according to global minimum and maximum values
  2. Utilize the MinMaxScaler object to standardize the test data according to global minimum and maximum values
  3. Utilize a cross-validation process rather than a train-test split process to remove the need for standardizing data
  4. Utilize the Pipeline API to standardize the training data according to the test data's summary statistics
  5. Utilize the Pipeline API to standardize the test data according to the training data's summary statistics
Show answer and explanation

Correct answer: E. Utilize the Pipeline API to standardize the test data according to the training data's summary statistics

The concern raised by the colleague is data leakage: standardizing all features before splitting causes test data statistics to influence the scaler's parameters, contaminating the test set. The scaler learns mean and standard deviation from the entire dataset, including test data. The correct approach uses a Pipeline API to fit the scaler only on training data, then apply those learned statistics to transform the test data. This ensures the test set is standardized using only training data's summary statistics, preventing information from the test set from influencing model evaluation.

Why the other options are wrong

  • A. MinMaxScaler has the same data leakage problem as StandardScaler; using global min/max values still requires fitting on the full dataset before splitting.
  • B. Standardizing test data according to global minimum and maximum values still involves fitting on the complete dataset before the split, perpetuating the data leakage issue.
  • C. Cross-validation does not address the core problem; standardization must still be performed correctly within each fold to avoid leakage.
  • D. This reverses the correct approach, standardizing training data according to test statistics would introduce test information into training, which is incorrect and even more problematic.

Question 17

An organization is developing a feature repository and is electing to one-hot encode all categorical feature variables. A data scientist suggests that the categorical feature variables should not be one-hot encoded within the feature repository. Which of the following explanations justifies this suggestion?

  1. One-hot encoding is not supported by most machine learning libraries.
  2. One-hot encoding is dependent on the target variable’s values which differ for each application.
  3. One-hot encoding is computationally intensive and should only be performed on small samples of training sets for individual machine learning problems.
  4. One-hot encoding is not a common strategy for representing categorical feature variables numerically.
  5. One-hot encoding is a potentially problematic categorical variable strategy for some machine learning algorithms.
Show answer and explanation

Correct answer: E. One-hot encoding is a potentially problematic categorical variable strategy for some machine learning algorithms.

One-hot encoding creates a problem for feature repositories because different machine learning use cases may require different handling of categorical variables. Tree-based models handle categorical variables directly and may perform worse with one-hot encoding due to increased dimensionality. Linear models, neural networks, and other algorithms have different requirements. By one-hot encoding in the repository, the organization restricts flexibility for different applications. The encoding decision should be made per application, not at the repository level. Options A, B, C, and D are factually incorrect regarding encoding characteristics.

Why the other options are wrong

  • A. One-hot encoding is widely supported by virtually all machine learning libraries.
  • B. One-hot encoding depends on the categorical variable's categories, not the target variable.
  • C. One-hot encoding is not computationally intensive and is a standard preprocessing step for all dataset sizes.
  • D. One-hot encoding is one of the most common and widely used strategies for numerical representation of categorical variables.

Question 18

Which of the following machine learning algorithms typically uses bagging?

  1. Gradient boosted trees
  2. K-means
  3. Random forest
  4. Linear regression
  5. Decision tree
Show answer and explanation

Correct answer: C. Random forest

Random forest is an ensemble algorithm that uses bootstrap aggregation (bagging) as its core technique. Random forests create multiple decision trees from bootstrap samples of the training data and aggregate their predictions. Gradient boosted trees use boosting, not bagging; K-means is an unsupervised clustering algorithm unrelated to bagging; linear regression does not use bagging; and individual decision trees do not inherently use bagging.

Why the other options are wrong

  • A. Gradient boosted trees use boosting, which sequentially builds trees to correct previous errors.
  • B. K-means is an unsupervised clustering algorithm that does not use bagging.
  • D. Linear regression does not use bagging as part of its standard algorithm.
  • E. Individual decision trees do not use bagging; bagging creates an ensemble of multiple trees.

Question 19

A data scientist has created two linear regression models. The first model uses price as a label variable and the second model uses log(price) as a label variable. When evaluating the RMSE of each model by comparing the label predictions to the actual price values, the data scientist notices that the RMSE for the second model is much larger than the RMSE of the first model. Which of the following possible explanations for this difference is invalid?

  1. The second model is much more accurate than the first model
  2. The data scientist failed to exponentiate the predictions in the second model prior to computing the RMSE
  3. The data scientist failed to take the log of the predictions in the first model prior to computing the RMSE
  4. The first model is much more accurate than the second model
  5. The RMSE is an invalid evaluation metric for regression problems
Show answer and explanation

Correct answer: E. The RMSE is an invalid evaluation metric for regression problems

RMSE is a valid and commonly used evaluation metric for regression problems. The question asks which explanation is invalid, making E the correct answer. Options A through D describe plausible explanations for why the second model's RMSE appears larger: the first model could genuinely be more accurate, or the data scientist may have failed to properly transform predictions back to the original scale before computing RMSE. Option B is plausible because forgetting to exponentiate log-transformed predictions would indeed inflate RMSE values.

Why the other options are wrong

  • A. If the first model is genuinely more accurate, its RMSE would legitimately be smaller.
  • B. Failing to exponentiate predictions from the log model before comparing to actual prices would produce inflated RMSE values.
  • C. Failing to log-transform first model predictions before comparison would also affect RMSE comparisons.
  • D. If the first model is genuinely more accurate, it would have lower RMSE.

Question 20

A data scientist uses 3-fold cross-validation and the following hyperparameter grid when optimizing model hyperparameters via grid search for a classification problem: Hyperparameter 1: [2, 5, 10] Hyperparameter 2: [50, 100] Which of the following represents the number of machine learning models that can be trained in parallel during this process?

  1. 3
  2. 5
  3. 6
  4. 18
Show answer and explanation

Correct answer: D. 18

Grid search evaluates every combination of hyperparameters. With Hyperparameter 1 having 3 values and Hyperparameter 2 having 2 values, there are 3 × 2 = 6 unique hyperparameter combinations. With 3-fold cross-validation, each combination is trained 3 times (once for each fold), resulting in 6 × 3 = 18 total models that can be trained in parallel across the folds.

Why the other options are wrong

  • A. 3 is the number of folds, not the number of models trainable in parallel.
  • B. 5 has no basis in the calculation of hyperparameter combinations or cross-validation splits.
  • C. 6 is the number of hyperparameter combinations, but does not account for the 3-fold cross-validation multiplier.

Question 21

A machine learning engineer is trying to scale a machine learning pipeline by distributing its feature engineering process. Which of the following feature engineering tasks will be the least efficient to distribute?

  1. One-hot encoding categorical features
  2. Target encoding categorical features
  3. Imputing missing feature values with the mean
  4. Imputing missing feature values with the true median
  5. Creating binary indicator features for missing values
Show answer and explanation

Correct answer: D. Imputing missing feature values with the true median

Imputing missing values with the true median requires computing the exact median across the entire dataset, necessitating a global aggregation operation. Computing the median is inherently more expensive than computing the mean, requiring sorting or full-data scans, and cannot be efficiently computed in a streaming or distributed manner without materializing significant data. In contrast, mean imputation and one-hot encoding can be computed more efficiently through distributed aggregations.

Why the other options are wrong

  • A. One-hot encoding can be efficiently distributed by processing each partition independently.
  • B. Target encoding requires global aggregations but is more efficient than median computation.
  • C. Mean imputation requires only a simple average across distributed data, which is efficient to parallelize.
  • E. Creating binary indicators for missing values is a simple column operation that parallelizes efficiently.

Question 22

A machine learning engineer is trying to perform batch model inference. They want to get predictions using the linear regression model saved at the path model_uri for the DataFrame batch_df. batch_df has the following schema: customer_id STRING The machine learning engineer runs the following code block to perform inference on batch_df using the linear regression model at model_uri: In which situation will the machine learning engineer’s code block perform the desired inference?

  1. When the Feature Store feature set was logged with the model at model_uri
  2. When all of the features used by the model at model_uri are in a Spark DataFrame in the PySpark
  3. When the model at model_uri only uses customer_id as a feature
  4. This code block will not perform the desired inference in any situation.
  5. When all of the features used by the model at model_uri are in a single Feature Store table
Show answer and explanation

Correct answer: A. When the Feature Store feature set was logged with the model at model_uri

The code uses fs.score_batch() with only a batch_df containing customer_id, which is insufficient for model inference on its own. For this code to work, the model at model_uri must have been logged together with a Feature Store feature set. When a feature set is logged with the model, the Feature Store automatically knows how to retrieve all required features using the customer_id from batch_df, enabling proper batch inference without requiring all features to be explicitly present in the input DataFrame.

Why the other options are wrong

  • B. Having all features in a Spark DataFrame does not guarantee they will be automatically retrieved; fs.score_batch() requires Feature Store integration to fetch features by key.
  • C. If the model uses only customer_id as a feature, it would require no inference at all, and score_batch() is designed for models with multiple retrieved features.
  • D. The code can perform desired inference in the correct situation where features are managed by Feature Store.
  • E. While having all features in a single Feature Store table is helpful, the model must be logged with the feature set for fs.score_batch() to know how to retrieve them automatically.

Question 23

A data scientist has created a linear regression model that uses log(price) as a label variable. Using this model, they have performed inference and the predictions and actual label values are in Spark DataFrame preds_df. They are using the following code block to evaluate the model: regression_evaluator.setMetricName("rmse").evaluate(preds_df) Which of the following changes should the data scientist make to evaluate the RMSE in a way that is comparable with price?

  1. They should exponentiate the computed RMSE value
  2. They should take the log of the predictions before computing the RMSE
  3. They should evaluate the MSE of the log predictions to compute the RMSE
  4. They should exponentiate the predictions before computing the RMSE
Show answer and explanation

Correct answer: D. They should exponentiate the predictions before computing the RMSE

The model predicts log(price), not price directly. To evaluate RMSE in units comparable to the original price variable, the predictions must be exponentiated to convert them back from log space to the original price scale. Computing RMSE on the exponentiated predictions yields an error metric in terms of actual price units, making it interpretable and comparable to models trained on the original price variable.

Why the other options are wrong

  • A. Exponentiating only the RMSE value without first converting predictions back to price scale produces a meaningless metric.
  • B. Taking the log of predictions is incorrect since predictions are already in log space from the model's output.
  • C. Evaluating MSE instead of RMSE and not converting back to price scale does not solve the comparability problem.

Question 24

A data scientist has been given an incomplete notebook from the data engineering team. The notebook uses a Spark DataFrame spark_df on which the data scientist needs to perform further feature engineering. Unfortunately, the data scientist has not yet learned the PySpark DataFrame API. Which of the following blocks of code can the data scientist run to be able to use the pandas API on Spark?

  1. import pyspark.pandas as ps df = ps. DataFrame(spark_df)
  2. import pyspark.pandas as ps df = ps.to_pandas(spark_df)
  3. spark_df.to_pandas()
  4. import pandas as pd df = pd. DataFrame(spark_df)
Show answer and explanation

Correct answer: A. import pyspark.pandas as ps df = ps. DataFrame(spark_df)

The correct way to convert a Spark DataFrame to a pandas API on Spark DataFrame is to import the pyspark.pandas module and wrap the Spark DataFrame using ps.DataFrame(). This creates a new object that provides a pandas-compatible interface while maintaining the distributed execution model of the underlying Spark DataFrame.

Why the other options are wrong

  • B. ps.to_pandas() converts to a pandas DataFrame on a single node, not to a pandas API on Spark DataFrame.
  • C. to_pandas() converts to a single-node pandas DataFrame, losing distributed processing capabilities.
  • D. pd.DataFrame() uses the pandas library which creates a single-node DataFrame and does not leverage Spark's distributed computation.

Question 25

A data scientist has produced two models for a single machine learning problem. One of the models performs well when one of the features has a value of less than 5, and the other model performs well when the value of that feature is greater than or equal to 5. The data scientist decides to combine the two models into a single machine learning solution. Which of the following terms is used to describe this combination of models?

  1. Bootstrap aggregation
  2. Support vector machines
  3. Bucketing
  4. Ensemble learning
  5. Stacking
Show answer and explanation

Correct answer: D. Ensemble learning

Ensemble learning is the practice of combining multiple models to produce better predictive performance than any single model alone. In this scenario, two models are combined based on different decision boundaries for a feature, creating an ensemble where each model contributes its strengths in different regions of the feature space. Bootstrap aggregation is a specific ensemble technique; support vector machines are an algorithm; bucketing refers to data partitioning; and stacking is a specific ensemble method where models are combined through another model.

Why the other options are wrong

  • A. Bootstrap aggregation is a specific ensemble method, but the general term is ensemble learning.
  • B. Support vector machines are a supervised learning algorithm, not a model combination technique.
  • C. Bucketing refers to partitioning data into groups, not combining models.
  • E. Stacking is a specific ensemble technique where a meta-learner combines base models, not the general concept.

25 questions in. Want the rest? The first half of the pack, free by email · The full pack

Question 26

In which of the following situations is it preferable to impute missing feature values with their median value over the mean value?

  1. When the features are of the categorical type
  2. When the features are of the boolean type
  3. When the features contain a lot of extreme outliers
  4. When the features contain no outliers
  5. When the features contain no missing values
Show answer and explanation

Correct answer: C. When the features contain a lot of extreme outliers

The median is more robust to extreme outliers than the mean because it represents the middle value and is not influenced by tail values. When features contain many outliers, using the mean would skew imputed values toward the extreme values, while the median provides a more representative central value. Options A, B, and E are invalid contexts for median imputation. Option D describes a scenario where outliers are absent, making the distinction between median and mean less relevant.

Why the other options are wrong

  • A. Categorical features use different imputation strategies such as mode, not median or mean.
  • B. Boolean features are categorical and do not use numerical imputation methods.
  • D. When no outliers exist, median and mean values are similar, so the choice is less critical.
  • E. Missing values must exist to perform imputation.

Question 27

A data scientist wants to efficiently tune the hyperparameters of a scikit-learn model in parallel. They elect to use the Hyperopt library to facilitate this process. Which of the following Hyperopt tools provides the ability to optimize hyperparameters in parallel?

  1. fmin
  2. SparkTrials
  3. quniform
  4. search_space
  5. objective_function
Show answer and explanation

Correct answer: B. SparkTrials

SparkTrials is the Hyperopt tool that enables parallel hyperparameter optimization by distributing trials across a Spark cluster. The fmin function (A) is the main optimization function but does not inherently provide parallelization, it requires SparkTrials as a parameter to achieve parallel execution. quniform (C) is a search space distribution function, search_space (D) defines hyperparameter ranges, and objective_function (E) defines the optimization objective, none of which provide parallelization.

Why the other options are wrong

  • A. fmin is the optimization function but it does not provide parallel execution; parallelization requires passing SparkTrials as the trials parameter.
  • C. quniform is a distribution function used to define hyperparameter search spaces, not a parallelization tool.
  • D. search_space is used to define the hyperparameter ranges and distributions to search over, not to enable parallel optimization.
  • E. objective_function is the user-defined function to optimize, not the tool for parallel execution.

Question 28

The implementation of linear regression in Spark ML first attempts to solve the linear regression problem using matrix decomposition, but this method does not scale well to large datasets with a large number of variables. Which of the following approaches does Spark ML use to distribute the training of a linear regression model for large data?

  1. Logistic regression
  2. Spark ML cannot distribute linear regression training
  3. Iterative optimization
  4. Least-squares method
  5. Singular value decomposition
Show answer and explanation

Correct answer: C. Iterative optimization

Spark ML uses iterative optimization algorithms, particularly gradient descent and related variants, to train linear regression models at scale. Iterative optimization does not require forming large matrices and naturally distributes across clusters by processing mini-batches of data. Matrix decomposition methods do not scale to large feature sets, making iterative approaches necessary. Logistic regression is a different algorithm; Spark ML does support distributed linear regression; least-squares is the objective but not the distributed method; and singular value decomposition is the matrix method that doesn't scale well.

Why the other options are wrong

  • A. Logistic regression is a different supervised learning algorithm for classification.
  • B. Spark ML explicitly supports distributed linear regression training.
  • D. Least-squares describes the objective function, not the distributed training method.
  • E. Singular value decomposition is the matrix method that does not scale well, not the solution.

Question 29

Which of the following statements describes a Spark ML estimator?

  1. An estimator is a hyperparameter grid that can be used to train a model
  2. An estimator chains multiple algorithms together to specify an ML workflow
  3. An estimator is a trained ML model which turns a DataFrame with features into a DataFrame with predictions
  4. An estimator is an algorithm which can be fit on a DataFrame to produce a Transformer
  5. An estimator is an evaluation tool to assess to the quality of a model
Show answer and explanation

Correct answer: D. An estimator is an algorithm which can be fit on a DataFrame to produce a Transformer

A Spark ML estimator is an algorithm that can be fit on a DataFrame to produce a Transformer. Estimators encapsulate the learning algorithm and have a fit() method that trains on data. Once fit, an estimator produces a Transformer object that can apply the learned model to new data. A hyperparameter grid is used with estimators but is not an estimator itself; a Pipeline chains algorithms; a fitted model is a Transformer, not an estimator; and evaluation tools are evaluators, not estimators.

Why the other options are wrong

  • A. A hyperparameter grid is a separate construct used with estimators, not the estimator itself.
  • B. Chaining multiple algorithms together describes a Pipeline, not an individual estimator.
  • C. A trained model that makes predictions is a Transformer, which is the output of fitting an estimator.
  • E. Model evaluation tools are evaluators or evaluator objects, not estimators.

Question 30

Which of the following describes the relationship between native Spark DataFrames and pandas API on Spark DataFrames?

  1. pandas API on Spark DataFrames are single-node versions of Spark DataFrames with additional metadata
  2. pandas API on Spark DataFrames are more performant than Spark DataFrames
  3. pandas API on Spark DataFrames are made up of Spark DataFrames and additional metadata
  4. pandas API on Spark DataFrames are less mutable versions of Spark DataFrames
Show answer and explanation

Correct answer: C. pandas API on Spark DataFrames are made up of Spark DataFrames and additional metadata

pandas API on Spark DataFrames is a wrapper layer that sits on top of native Spark DataFrames, combining the underlying distributed Spark DataFrame with additional metadata and a pandas-compatible API. This allows users familiar with pandas to write code in familiar syntax while leveraging Spark's distributed computing capabilities. The pandas API on Spark DataFrame is not a separate engine but an abstraction built from Spark DataFrames.

Why the other options are wrong

  • A. pandas API on Spark DataFrames are distributed, not single-node; they maintain the distributed nature of Spark DataFrames.
  • B. pandas API on Spark DataFrames typically have slightly higher overhead due to the abstraction layer, making them not more performant than native Spark DataFrames.
  • D. pandas API on Spark DataFrames have similar mutability characteristics to Spark DataFrames; this description does not accurately characterize their relationship.

Question 31

A machine learning engineer is trying to scale a machine learning pipeline pipeline that contains multiple feature engineering stages and a modeling stage. As part of the cross-validation process, they are using the following code block: A colleague suggests that the code block can be changed to speed up the tuning process by passing the model object to the estimator parameter and then placing the updated cv object as the final stage of the pipeline in place of the original model. Which of the following is a negative consequence of the approach suggested by the colleague?

  1. The model will take longer to train for each unique combination of hyperparameter values
  2. The feature engineering stages will be computed using validation data
  3. The cross-validation process will no longer be parallelizable
  4. The cross-validation process will no longer be reproducible
  5. The model will be refit one more per cross-validation fold
Show answer and explanation

Correct answer: B. The feature engineering stages will be computed using validation data

When nesting a GridSearchCV object inside a pipeline as the final estimator, the feature engineering stages are fitted on the entire dataset before cross-validation occurs. During cross-validation, the GridSearchCV will split the data into train/validation folds, but the feature transformations were already learned from the complete dataset (including validation data). This causes data leakage because the feature engineering has seen information from the validation folds, violating the principle that validation data should be held out during model training and feature engineering.

Why the other options are wrong

  • A. Training time per hyperparameter combination would not increase; nesting GridSearchCV doesn't fundamentally change per-combination training logic.
  • C. GridSearchCV with parallelism=2 remains parallelizable; nesting doesn't remove this capability.
  • D. The process remains reproducible because the seed parameter is still set to 42.
  • E. The model is not refit an additional time; the number of refits equals the number of folds times parameter combinations, which doesn't change by nesting.

That was 31 of 140.

The full Databricks Machine Learning Associate pack has all 140 questions, each with the answer, the explanation and why the other options are wrong, plus a questions-only copy for timed runs. US$39, paid once, with free monthly updates and a pass-or-your-money-back guarantee.

Get the full pack

Not ready yet? Get the first 68 free as one PDF by email. Get the Half Pack →