Databricks Machine Learning Associate · Section 3 · 31% of the exam
Identify the number of models being trained in conjunction with a grid-search and cross-validation process.
One of the objectives of the Databricks Certified Machine Learning Associate exam, in the section “Model Development”. Here is what it covers, the points to remember and a question to try.
What it covers
A train-validation split scores each candidate once; k-fold cross-validation scores it k times on rotating folds, which is more reliable but k times more expensive. A grid search with cross-validation trains (number of combinations) x k models, plus one refit of the best combination. Comparing training and validation error reveals underfitting (high bias) or overfitting (high variance).
Points to remember
- Training set fits parameters, validation data selects hyperparameters, the test set is used once for the final estimate.
- Train-validation split: one model per combination, cheap, less reliable on small data. k-fold CV: k models per combination, about k times the cost, more robust, and every row is validated once.
- Spark defaults:
CrossValidator(numFolds=3, parallelism=1),TrainValidationSplit(trainRatio=0.75). scikit-learn uses 5 folds whencv=None(stratified for classifiers). CrossValidatoris an estimator;fit()returns aCrossValidatorModelwithbestModelandavgMetrics, and refits the best combination on the whole input dataset.- Models during grid search with CV = (product of the values per hyperparameter) x k; the sample answer is 18 x 5 = 90. Add 1 only when the refit is counted.
Try a question
A team tunes 20 hyperparameter combinations for a Spark ML model on a 900-million-row table. Each fit takes about 90 minutes and they need results within two days. A 25% validation slice of this table is large enough to be representative. Which tuning setup is most appropriate?
- A
TrainValidationSplitwithtrainRatio=0.75 - B
CrossValidatorwithnumFolds=10for the most reliable estimate - C
CrossValidatorwithnumFolds=5andparallelism=1 - DScore each combination on the training data to save time
Show the answer
A. Cross-validation is most valuable on small or medium datasets. When data is plentiful and each fit is expensive, a train-validation split gives a dependable estimate for a fraction of the cost: 21 fits versus at least 61 for 3-fold cross-validation.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Cross-Validation, Counting Models and the Bias-Variance Trade-off teaches this objective (about 45 minutes), and 19 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.
More in this section
- Use ML foundations to select the appropriate algorithm for a given model scenario
- Identify methods to mitigate data imbalance in training data
- Compare estimators and transformers
- Develop a training pipeline
- Use Hyperopt's fmin operation to tune a model's hyperparameters
- Perform random or grid search or Bayesian search as a method for tuning hyperparameters.
- Parallelize single node models for hyperparameter tuning
- Describe the benefits and downsides of using cross-validation over a train-validation split.
- Perform cross-validation as a part of model fitting.
- Use common classification metrics: F1, Log Loss, ROC/AUC, etc
- Use common regression metrics: RMSE, MAE, R-squared, etc.
- Choose the most appropriate metric for a given scenario objective