Machine Learning Associate · 19% of the exam

ML Workflows: free practice questions

5 sample questions from our 88-question bank for this domain — answers and explanations included. These are the same scenario-based style as the real Databricks exam.

1. A data scientist computes the Pearson correlation matrix for a 20-feature dataset and finds that features `A` and `B` have a Pearson coefficient of 0.05, but a Spearman rank correlation of 0.72. Which of the following BEST explains this discrepancy?

  • A. The Spearman coefficient is always higher than Pearson for large datasets, so this is expected
  • B. Features `A` and `B` likely have a strong monotonic but non-linear relationship, which Spearman captures but Pearson does not✓ Correct
  • C. Pearson is unreliable for datasets with more than 15 features and should be replaced by Spearman in all EDA
  • D. The data likely has a high percentage of missing values that are inflating the Spearman coefficient
Explanation

Pearson correlation measures only linear relationships between two variables. Spearman rank correlation measures the strength of any monotonic relationship (linear or non-linear) by operating on the ranks of the values. A low Pearson but high Spearman coefficient is a classic indicator that the two features have a strong monotonic but non-linear relationship (e.g., exponential or power-law). Spearman is not always higher than Pearson — this claim is false and reflects a misconception. Pearson's reliability is not related to the number of features in the dataset; it is always valid as a measure of linear association. Missing values do not inflate Spearman scores; both methods handle missing values similarly, and missing values would more likely reduce correlation estimates.

2. A data scientist is building a correlation heatmap for a 30-feature dataset. They compute pairwise Pearson correlations and notice that the features `zip_code` (a 5-digit integer stored as a number) and `median_home_price` show a surprisingly high Pearson correlation of 0.82. Which of the following is the BEST concern to raise about this finding?

  • A. The Pearson correlation of 0.82 conclusively proves causality: higher zip codes directly cause higher home prices.
  • B. `zip_code` is a nominal categorical identifier encoded as an integer; Pearson correlation assumes a linear relationship between continuous variables, so the 0.82 value is likely a spurious artifact of the numeric encoding rather than a meaningful linear relationship.✓ Correct
  • C. Pearson correlation only accepts values between -1 and 0, so a value of 0.82 indicates a software bug in the computation.
  • D. A Pearson correlation above 0.7 is automatically flagged as multicollinearity by Spark's correlation engine and should be removed from the dataset before modeling.
Explanation

Option B is correct. `zip_code` is a nominal categorical variable — the numeric values assigned to zip codes have no inherent linear ordering or magnitude meaning (zip code 90210 is not '90210 units' of anything). Pearson correlation measures the strength of a linear relationship between two continuous variables. Treating `zip_code` as a continuous numeric feature and computing Pearson correlation produces a statistically meaningless number that reflects the arbitrary numeric encoding rather than any genuine linear association. Option A is wrong: Correlation does not imply causation, and a high Pearson value between a nominal variable and a continuous variable is likely spurious, making any causal interpretation doubly wrong. Option C is wrong: Pearson correlation ranges from -1 to +1, so 0.82 is a valid output range. There is no software bug. Option D is wrong: Spark does not automatically flag or remove features based on correlation thresholds. Multicollinearity detection is a modeling step performed by the data scientist, not an automatic Spark behavior.

3. A data scientist is performing EDA on a PySpark DataFrame `employee_df` with a column `salary`. They want to detect outliers using the IQR method in PySpark. Which code snippet CORRECTLY implements this?

  • A. ```python from pyspark.sql.functions import col from pyspark.ml.feature import QuantileDiscretizer q1, q3 = employee_df.approxQuantile('salary', [0.25, 0.75], 0.01) iqr = q3 - q1 outliers = employee_df.filter((col('salary') < q1 - 1.5 * iqr) | (col('salary') > q3 + 1.5 * iqr)) ```✓ Correct
  • B. ```python from pyspark.sql.functions import col, stddev, mean stats = employee_df.select(mean('salary'), stddev('salary')).collect()[0] outliers = employee_df.filter((col('salary') < stats[0] - 1.5 * stats[1]) | (col('salary') > stats[0] + 1.5 * stats[1])) ```
  • C. ```python q1, q3 = employee_df.describe('salary').filter(col('summary').isin(['25%','75%'])).collect() iqr = float(q3['salary']) - float(q1['salary']) outliers = employee_df.filter((col('salary') < q1 - 1.5 * iqr) | (col('salary') > q3 + 1.5 * iqr)) ```
  • D. ```python import pyspark.sql.functions as F iqr = employee_df.agg(F.expr('percentile(salary, 0.75) - percentile(salary, 0.25)')).collect()[0][0] outliers = employee_df.filter((col('salary') < -1.5 * iqr) | (col('salary') > 1.5 * iqr)) ```
Explanation

A is correct: `DataFrame.approxQuantile('salary', [0.25, 0.75], 0.01)` is the standard PySpark API for computing the first and third quartiles (with a small relative error tolerance of 0.01), and the IQR fence formula `q1 - 1.5*IQR` / `q3 + 1.5*IQR` is correctly applied. B is incorrect because it uses mean and standard deviation — that is the Z-score method, not the IQR method. C is incorrect because PySpark's `describe()` does not return quartile rows labeled '25%' and '75%'; it only returns count, mean, stddev, min, and max — this would fail at runtime. D is incorrect because while `percentile()` can compute Q1 and Q3, the filter omits adding/subtracting from Q1 and Q3 respectively — it incorrectly uses only `±1.5*IQR` relative to zero, which is a logic error.

4. During EDA, an analyst notices that a feature column `annual_income` in a PySpark DataFrame has a right-skewed distribution with a skewness value of 3.8. Which TWO of the following actions would be MOST appropriate to address this skewness before using the feature in a linear regression model? (Select TWO)

  • A. Apply a log transformation to the `annual_income` column to reduce skewness.✓ Correct
  • B. Replace all values above the 95th percentile with the median to cap outliers.
  • C. Apply a square root or Box-Cox transformation to normalize the distribution.✓ Correct
  • D. Drop all rows where `annual_income` is above the mean plus one standard deviation.
  • E. Bin the `annual_income` column into equal-frequency buckets and treat it as categorical.
  • F. Standardize the column using z-score normalization to center it around zero.
Explanation

Log transformation (A) and power/Box-Cox transformations (C) are the standard, widely accepted techniques for reducing positive skewness in a continuous variable before linear modeling — they compress the long right tail and make the distribution more Gaussian-like. Option B (capping at 95th percentile) is a form of winsorizing used for outlier handling, not skewness correction, and discards information. Option D (dropping rows above mean+1 SD) would remove a large portion of valid data (roughly 16% by definition) and introduces significant bias. Option E (binning into categorical) loses the continuous nature of the variable and may not be appropriate for linear regression. Option F (z-score standardization) changes the scale and center but does NOT change the shape or skewness of the distribution.

5. A data scientist is building a feature engineering pipeline using Delta Live Tables (DLT) on Databricks. They define a bronze table that ingests raw clickstream events, a silver table that cleans and deduplicates the data, and a gold table that computes session-level aggregation features. Which of the following statements about using DLT for feature engineering pipelines is MOST accurate?

  • A. DLT pipelines cannot read from or write to Delta tables; they require a separate storage format such as Parquet.
  • B. DLT automatically manages incremental data processing using `APPLY CHANGES INTO`, ensuring that only new or changed records are reprocessed as data arrives, making it efficient for continuously updated feature tables.✓ Correct
  • C. DLT gold tables defined with `@dlt.table` cannot be registered in the Databricks Feature Store because DLT manages its own metadata catalog separately.
  • D. DLT pipelines require all transformations to be defined in SQL; Python-based feature engineering logic is not supported.
Explanation

DLT is designed for incremental, declarative data pipelines. The `APPLY CHANGES INTO` command (CDC support) and DLT's incremental processing semantics ensure that, as new events arrive, only affected records are reprocessed through the bronze-silver-gold layers. This makes it highly efficient for maintaining up-to-date feature tables in a production environment. Option A is completely incorrect: DLT is built entirely on Delta Lake; every DLT table is a Delta table stored in cloud storage. Option C is incorrect: DLT-managed tables are registered in the Unity Catalog (or the workspace's Hive metastore), and the Databricks Feature Store can create or read feature tables from any Delta table — DLT-managed tables included. Option D is incorrect: DLT supports both Python (using the `@dlt.table` and `@dlt.view` decorators) and SQL, giving full flexibility for Python-based feature engineering logic.

83 more questions in this domain

Practice the full bank with instant grading, flashcards, and a timed mock exam.

Start practicing free
ML Workflows — Free Machine Learning Associate Practice Questions | DataCertPrep — Certification Prep