Free Databricks Machine Learning Associate practice questions

10 free Databricks Machine Learning Associate practice questions with the correct answer and a full explanation for each, taken from the CertStash pack of 140 questions. Work through them, then open each answer to check your reasoning.

Question 1

A machine learning engineer has created a Feature Table new_table using Feature Store Client fs.

When creating the table, they specified a metadata description with key information about the Feature Table. They now want to retrieve that metadata programmatically.

Which of the following lines of code will return the metadata description?

  1. There is no way to return the metadata description programmatically.
  2. fs.create_training_set("new_table")
  3. fs.get_table("new_table").description
  4. fs.get_table("new_table").load_df()
  5. fs.get_table("new_table")
Show answer and explanation

Correct answer: C. fs.get_table("new_table").description

The Feature Store Client provides a get_table() method that returns a table object containing metadata properties. The description attribute of this table object holds the metadata description that was specified during table creation. This allows programmatic access to the description without needing to recreate or reload the table.

Why the other options are wrong

  • A. Metadata descriptions can be retrieved programmatically through the Feature Store API.
  • B. create_training_set() is used to create training datasets, not to retrieve table metadata.
  • D. load_df() loads the actual data from the table, not its metadata properties.
  • E. While get_table() returns the table object, accessing it without the .description attribute does not return the description string itself.

Question 2

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 price is greater than 0.

Which of the following code blocks will accomplish this task?

  1. spark_df[spark_df["price"] > 0]
  2. spark_df.filter(col("price") > 0)
  3. SELECT * FROM spark_df WHERE price > 0
  4. spark_df.loc[spark_df["price"] > 0,:]
  5. spark_df.loc[:,spark_df["price"] > 0]
Show answer and explanation

Correct answer: B. spark_df.filter(col("price") > 0)

The Spark DataFrame API uses the filter() method to subset rows based on conditions. The col() function from pyspark.sql.functions creates a Column object representing the column reference, and the condition col("price") > 0 creates a boolean expression that filter() evaluates. This is the standard and correct Spark syntax for filtering operations.

Why the other options are wrong

  • A. Standard pandas indexing syntax does not work directly on Spark DataFrames.
  • C. SQL SELECT syntax cannot be executed on a DataFrame object directly without first creating a SQL view.
  • D. The .loc accessor is a pandas method and is not available on Spark DataFrames.
  • E. This pandas syntax targets columns rather than rows and does not work with Spark DataFrames.

Question 3

A health organization is developing a classification model to determine whether or not a patient currently has a specific type of infection. The organization's leaders want to maximize the number of positive cases identified by the model.

Which of the following classification metrics should be used to evaluate the model?

  1. RMSE
  2. Precision
  3. Area under the residual operating curve
  4. Accuracy
  5. Recall
Show answer and explanation

Correct answer: E. Recall

Recall measures the proportion of actual positive cases that the model correctly identifies, calculated as true positives divided by all actual positives. When the goal is to maximize the number of positive cases identified, recall is the appropriate metric because it directly measures how many of the true infections are caught by the model, which is critical in a health context.

Why the other options are wrong

  • A. RMSE is a regression metric, not applicable to classification problems.
  • B. Precision measures the accuracy of positive predictions but does not directly optimize for identifying the maximum number of positive cases.
  • C. The residual operating curve is not a standard classification metric and does not apply to this scenario.
  • D. Accuracy measures overall correctness but does not prioritize identifying positive cases and can be misleading with imbalanced datasets.

Question 4

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 a robust measure of central tendency that is not affected by extreme outliers, whereas the mean is heavily influenced by outliers. When features contain extreme outliers, imputing with the median produces values more representative of the typical data distribution, avoiding the distortion that would result from using a mean pulled toward the extreme values.

Why the other options are wrong

  • A. Median imputation is not appropriate for categorical features; categorical imputation requires different strategies.
  • B. Boolean features are binary and do not typically use median imputation methods.
  • D. When features contain no outliers, the mean and median are generally similar, making the choice between them less critical.
  • E. Features with no missing values do not require imputation strategies.

Question 5

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 a binary indicator feature for each original feature with missing values preserves the information about which rows had imputed values. This allows the machine learning algorithm to learn whether the pattern of missingness itself is predictive, capturing the valuable signal that missingness represents without discarding information. This technique is known as missing value imputation with indicator variables.

Why the other options are wrong

  • A. Switching from median to mean imputation does not address the colleague's concern about losing information about which values were missing.
  • B. Most machine learning algorithms cannot handle missing values and require imputation before training.
  • C. Removing features entirely discards all the information they contain, not preserving it.
  • E. Creating a constant feature with uniform percentage values for each feature provides no row-level variation and fails to capture which specific rows had missing values.

Question 6

A data scientist is wanting to explore summary statistics for Spark DataFrame spark_df. The data scientist wants to see the count, mean, standard deviation, minimum, maximum, and interquartile range (IQR) for each numerical feature.

Which of the following lines of code can the data scientist run to accomplish the task?

  1. spark_df.summary ()
  2. spark_df.stats()
  3. spark_df.describe().head()
  4. spark_df.printSchema()
  5. spark_df.toPandas()
Show answer and explanation

Correct answer: A. spark_df.summary ()

The summary() method on a Spark DataFrame returns a summary statistics table that includes count, mean, stddev, min, max, and quantiles (which enable IQR calculation) for all numerical features. This is the built-in Spark method designed for exploratory data analysis and provides exactly the statistics requested.

Why the other options are wrong

  • B. The stats() method is not a standard Spark DataFrame method.
  • C. The describe() method returns similar summary statistics but is less flexible than summary() and head() would only show the first row.
  • D. printSchema() displays column names and types, not summary statistics.
  • E. Converting to pandas loses the distributed computing benefits and is inefficient for large Spark DataFrames.

Question 7

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 tree-based machine learning algorithms and certain other models because it can introduce high dimensionality and multicollinearity issues. Additionally, the encoding requires predefined category knowledge at feature repository time, but different downstream applications may have different categorical values or need different encoding strategies based on their specific requirements, making one-hot encoding at the repository level inflexible.

Why the other options are wrong

  • A. One-hot encoding is widely supported by most machine learning libraries.
  • B. While one-hot encoding requires knowing the categorical values, it is not inherently dependent on the target variable's values.
  • C. One-hot encoding is not computationally intensive and is typically performed on entire datasets rather than just small samples.
  • D. One-hot encoding is a very common and well-established strategy for representing categorical variables numerically.

Question 8

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 well-established and valid evaluation metric for regression problems. It is widely used to measure prediction error and compare model performance. Declaring that RMSE is an invalid metric for regression is factually incorrect, this is not a possible explanation for the observed RMSE difference.

Why the other options are wrong

  • A. The second model could genuinely be more accurate if log transformation better captures the relationship in the data.
  • B. Failing to exponentiate predictions from the log-transformed model would result in comparing log-scale predictions against original-scale actual values, producing misleading RMSE values.
  • C. Failing to take logs of first model predictions would create an inconsistency where one model's predictions are on a different scale than the other's.
  • D. The first model could be more accurate if the log transformation was unnecessary or inappropriate for this data.

Question 9

A data scientist uses 3-fold cross-validation when optimizing model hyperparameters for a regression problem. The following root-mean-squared-error 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

The overall cross-validation error is calculated by averaging the error metrics across all folds. With RMSE values of 10.0, 12.0, and 17.0 across three folds, the mean is (10.0 + 12.0 + 17.0) / 3 = 39.0 / 3 = 13.0. This averaged metric represents the model's expected performance across the entire dataset.

Why the other options are wrong

  • B. 17.0 is only the error on a single fold, not the overall cross-validation metric.
  • C. 12.0 is the error on only one fold and does not represent the aggregate performance.
  • D. 39.0 is the sum of all fold errors, not the averaged cross-validation error.
  • E. 10.0 is the best individual fold result but not indicative of overall performance across folds.

Question 10

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 cros-alidation 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?

Exhibit for question 10

  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 a GridSearchCV (or similar cross-validator) object is placed as the final stage of a pipeline instead of the model, the feature engineering stages preceding it will be computed on the full dataset during each inner cross-validation fold, including validation data. This violates the principle of data leakage prevention in cross-validation. The feature engineering transformations should be fit only on training data and applied to validation data, not computed using validation data. This nested cross-validation approach causes the feature engineering stages to see and be influenced by validation data, compromising the integrity of the cross-validation process.

Why the other options are wrong

  • A. Training time per hyperparameter combination would not increase; if anything, parallelization improvements could offset any minor overhead from the nested structure.
  • C. The parallelism setting (parallelism=2) in the outer cross-validator would still function; inner parallel jobs may be limited but the structure remains parallelizable.
  • D. Reproducibility is maintained as the seed=42 parameter is still present and controls randomness in both the outer and inner cross-validation processes.
  • E. The model refitting pattern does not increase by one per fold; the refitting behavior follows the standard nested cross-validation structure without anomalous additional refits.

That was 10 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