Databricks Machine Learning Associate Question 238
Select 3You are tasked with building a machine learning model in Databricks to predict customer churn. To ensure the model generalizes well to unseen data, you decide to perform k-fold cross-validation. Which of the following steps are necessary to implement k-fold cross-validation in Databricks?
- A
Split the dataset into k equally sized folds and iterate through each fold as the validation set while training on the remaining folds.
- B
Use the
CrossValidatorclass from thepyspark.ml.tuningmodule to perform cross-validation. - C
Ensure that hyperparameter tuning is performed before cross-validation to speed up training.
- D
Specify an evaluation metric, such as accuracy or RMSE, when using cross-validation.
- E
Manually shuffle the dataset before splitting it into folds to ensure randomness.
Show answer and explanation
Correct answers: A, B, D
Explanation
To perform k-fold cross-validation in Databricks, the dataset is split into k folds, and the CrossValidator class is typically used to automate the process. You must also specify an evaluation metric to assess model performance. Hyperparameter tuning is usually integrated with cross-validation, and manual shuffling is unnecessary when using built-in tools like CrossValidator.
- A. Correct.
Correct: This is the fundamental process of k-fold cross-validation, where the dataset is split into k folds, and each fold is used as the validation set once.
- B. Correct.
Correct: The
CrossValidatorclass in Spark MLlib automates the cross-validation process, integrating it with model training and evaluation. - C. Incorrect.
Incorrect: Hyperparameter tuning is often performed during cross-validation, not before it. Cross-validation helps evaluate different hyperparameter combinations efficiently.
- D. Correct.
Correct: An evaluation metric must be specified to assess the model's performance during cross-validation and select the best model.
- E. Incorrect.
Incorrect: Shuffling is generally handled automatically by cross-validation implementations like the
CrossValidatorclass in Databricks, so manual shuffling is not required.