Databricks Machine Learning Professional Question 44
Select 3You are using Databricks to tune a machine learning model's hyperparameters with Hyperopt. To effectively track your experiments and model metrics, you want to enable autologging with MLflow. Which of the following steps are required to enable MLflow autologging in this scenario?
- A
Import the
mlflowandhyperoptlibraries into your notebook or script. - B
Call
mlflow.autolog()before defining your Hyperopt objective function. - C
Call
mlflow.start_run()before running the Hyperopt optimization process. - D
Set the
tracking_urifor MLflow usingmlflow.set_tracking_uri(). - E
Wrap the Hyperopt optimization function with
mlflow.log_model(). - F
Ensure the MLflow tracking server is running and accessible.
Show answer and explanation
Correct answers: A, C, F
Explanation
To enable autologging when using Hyperopt with MLflow, you need to start by importing the necessary libraries. Once the setup is complete, you must explicitly start an MLflow run using mlflow.start_run() because Hyperopt experiments do not automatically create runs for you. Additionally, the MLflow tracking server must be running and reachable to store the logged data. Using mlflow.autolog() is not applicable for Hyperopt, as it does not automatically track trials. Similarly, setting a tracking URI is optional and only required for remote tracking setups.
- A. Correct.
Correct: Importing the required libraries, such as
mlflowandhyperopt, is a necessary first step to use MLflow and Hyperopt together. - B. Incorrect.
Incorrect: While
mlflow.autolog()is useful in other contexts, it is not applicable for Hyperopt as MLflow does not automatically log Hyperopt trials using this function. - C. Correct.
Correct: Calling
mlflow.start_run()ensures that the metrics, parameters, and other details from the Hyperopt optimization process are logged under an active MLflow run. - D. Incorrect.
Incorrect: Setting a custom
tracking_uriis optional and only needed if you are using a remote MLflow tracking server. It is not strictly required to enable autologging. - E. Incorrect.
Incorrect:
mlflow.log_model()is used to log a model artifact explicitly, but it is unrelated to setting up autologging for Hyperopt experiments. - F. Correct.
Correct: Ensuring the MLflow tracking server is running and accessible is essential to log experiment data, especially if using a remote MLflow server.