Databricks Machine Learning Associate Question 234
Select 3You are training a machine learning model using a dataset stored in a Delta table on Databricks. To ensure that your model generalizes well to unseen data, you decide to use cross-validation during model fitting. Which of the following steps should you take to correctly implement cross-validation in your workflow?
- A
Split the dataset into training and test sets before performing cross-validation.
- B
Use the
CrossValidatorclass from Spark MLlib to divide the training data into k-folds and evaluate model performance. - C
Ensure that hyperparameter tuning is performed independently for each fold during cross-validation.
- D
Directly evaluate model performance on the test set during the cross-validation process.
- E
Aggregate the evaluation metrics from all folds to determine the overall model performance.
Show answer and explanation
Correct answers: B, C, E
Explanation
Cross-validation is a technique used to evaluate model performance by splitting the training data into k-folds and ensuring that each subset is used for validation exactly once while the rest are used for training. In Databricks, the CrossValidator class in Spark MLlib simplifies this process. Hyperparameter tuning during cross-validation ensures that the model is optimized, and aggregating metrics from all folds provides a reliable estimate of performance. The test set is reserved for final evaluation and should not be involved during cross-validation.
- A. Incorrect.
Splitting the dataset into training and test sets is a prerequisite for ensuring generalization but is not a part of the cross-validation process itself. Cross-validation is applied only to the training set, and the test set is left untouched for final evaluation.
- B. Correct.
The
CrossValidatorclass in Spark MLlib is a standard way to implement k-fold cross-validation in Databricks. It automates the process of dividing data into folds and evaluating the model on each fold. - C. Correct.
Hyperparameter tuning should be done independently for each fold during cross-validation to ensure that the model is optimized for each subset of training data and that the evaluation remains unbiased.
- D. Incorrect.
Evaluating model performance on the test set during cross-validation is incorrect because the test set should only be used for final evaluation after the model has been trained and validated.
- E. Correct.
Aggregating evaluation metrics from all folds is necessary to compute an overall performance metric, which provides a robust estimate of the model's generalization ability.