DATABRICKS-MACHINE-LEARNING-ASSOCIATE practice question 6 of 15
A data scientist is attempting to tune a logistic regression model logistic using scikit-learn. They want to specify a search space for two hyperparameters and let the tuning process randomly select values for each evaluation. They attempt to run the following code block, but it does not accomplish the desired task: Which of the following changes can the data scientist make to accomplish the task?
Full set: 74 questionsThe user's objective is to perform hyperparameter tuning by randomly selecting values from a specified search space. The GridSearchCV operation performs an exhaustive search, evaluating every possible combination of the provided hyperparameter values. This does not meet the requirement for random selection. The correct tool in the scikit-learn library for this task is RandomizedSearchCV, which samples a fixed number of parameter settings from the specified distributions. Replacing GridSearchCV with RandomizedSearchCV directly accomplishes the desired random tuning process.
B. crossvalidate is a function used to evaluate a model's performance with cross-validation but does not perform hyperparameter tuning over a search space.
C. ParameterGrid is a helper class that generates combinations of parameters but does not perform the actual model fitting or cross-validated search.
D. Changing the randomstate argument affects reproducibility but does not change the fundamental search algorithm from an exhaustive grid search to a random search.
E. GridSearchCV requires a list of discrete values for its parameters, not a statistical distribution. This change would cause an error and not alter the search method.
1. Official Databricks Documentation: In the "Hyperparameter tuning with scikit-learn and MLflow" guide
Databricks explains the two main approaches: "GridSearchCV...tries all possible combinations" and "RandomizedSearchCV...tries a fixed number of random combinations." This directly supports using RandomizedSearchCV for random selection.
Source: Databricks Documentation > Machine Learning > Model training > Hyperparameter tuning > scikit-learn and MLflow > Section: "Tune hyperparameters".
2. Official scikit-learn Documentation: The user guide explicitly contrasts the two methods. It states
"While GridSearchCV is a good method for finding parameters in a grid
RandomizedSearchCV can be preferred... It samples a given number of candidates from a parameter space with a specified distribution."
Source: scikit-learn User Guide > 3.2. Tuning the hyper-parameters of an estimator > Section 3.2.3. "Randomized search".
3. University Courseware: Stanford University's CS229 (Machine Learning) course materials often discuss hyperparameter tuning strategies
explaining that Grid Search can be computationally expensive and that Randomized Search is often a more efficient alternative for exploring a large parameter space.
Source: Stanford University
CS229: Machine Learning
Lecture Notes
"Advice for Applying Machine Learning
" Section on "Model Selection and Hyperparameter Tuning." (Illustrates the conceptual difference between grid and random search).
Keep practicing
Take the free DATABRICKS-MACHINE-LEARNING-ASSOCIATE practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DATABRICKS-MACHINE-LEARNING-ASSOCIATE practice questions
- Question 2The implementation of linear regression in Spark ML first attempts to solve the linear re…
- Question 3A data scientist wants to parallelize the training of trees in a gradient boosted tree to…
- Question 5Which of the Spark operations can be used to randomly split a Spark DataFrame into a trai…
- Question 7Which of the following is a benefit of using vectorized pandas UDFs instead of standard P…
- Question 8A data scientist is developing a machine learning pipeline using AutoML on Databricks Mac…
- Question 10Which of the following hyperparameter optimization methods automatically makes informed s…
