Databricks Machine Learning Associate exam dumps

Databricks Machine Learning Associate practice question 187 of 656

Databricks Certified Machine Learning Associate. Associate level, Databricks. Free question with the correct answer and a full explanation.

Databricks Machine Learning Associate Question 187

Single answer

You are working with a dataset on Databricks that contains missing values in a numeric column 'age'. You decide to impute the missing values using the mean of the column. Which of the following steps should you take to achieve this using PySpark?

  1. A

    Use the fillna method on the DataFrame and provide the mean value of the 'age' column.

  2. B

    Use the fillna method on the DataFrame and provide the median value of the 'age' column.

  3. C

    Calculate the mean of the 'age' column, then use the fillna method with the calculated mean.

  4. D

    Use the Databricks AutoML tool to automatically impute missing values with the mean.

Show answer and explanation

Correct answer: C

Explanation

To impute missing values in a numeric column with the mean using PySpark, you need to first calculate the mean of the column and then use the fillna method to replace the missing values. This ensures that the imputation is based on the actual mean value of the column, which is consistent with the requirement described in the question.

  • A. Incorrect.

    The fillna method can be used to fill missing values, but it requires a specific value to be provided. You must first calculate the mean of the 'age' column before using fillna, which is not done in this step.

  • B. Incorrect.

    The fillna method supports filling missing values, but the question specifies using the mean, not the median. This step does not align with the specified requirement.

  • C. Correct.

    This is the correct approach. You first calculate the mean of the 'age' column and then use the fillna method to impute the missing values with this calculated mean.

  • D. Incorrect.

    While Databricks AutoML can handle missing values, it is not explicitly designed for manual control over imputation with specific values (e.g., mean or median). This option does not meet the requirement of manually imputing with the mean.

Timed practice exam

Take a Databricks Machine Learning Associate practice test under exam conditions

48 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam