Databricks Machine Learning Professional Question 23
Select 4You are building a machine learning model to predict customer churn using Databricks and decide to manually log parameters, models, and evaluation metrics with MLflow. Which of the following steps must you take to ensure the logging is correctly implemented?
- A
Use
mlflow.log_param()to record hyperparameters such as learning rate and batch size. - B
Use
mlflow.log_metric()to log evaluation metrics like accuracy and F1-score. - C
Use
mlflow.log_artifact()to log the trained model artifact for later use. - D
Use
mlflow.log_model()to save the trained model with metadata such as input and output signatures. - E
Use
mlflow.set_tracking_uri()to specify the location of the MLflow tracking server.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
Logging parameters, metrics, and models is a crucial part of using MLflow for managing machine learning experiments. mlflow.log_param() and mlflow.log_metric() are used for hyperparameter and metric logging, respectively, while mlflow.log_model() is designed for saving the trained model with metadata. Additionally, mlflow.set_tracking_uri() is necessary to configure the tracking server location. While mlflow.log_artifact() is useful for logging additional files, it is not required for logging models.
- A. Correct.
mlflow.log_param()is the correct method to log hyperparameters, which are critical for experiment tracking and reproducibility. - B. Correct.
mlflow.log_metric()should be used to record evaluation metrics, as MLflow tracks these values across experiments. - C. Incorrect.
mlflow.log_artifact()is used to log arbitrary files (e.g., plots or text files) to MLflow, but it is not the correct method to log models. - D. Correct.
mlflow.log_model()is the proper function to save the trained model along with metadata, making it easy to deploy and reuse. - E. Correct.
mlflow.set_tracking_uri()is required to specify the tracking server location, ensuring that all logs and artifacts are stored in the correct backend.