Databricks Machine Learning Professional Question 20
Select 3You are building a machine learning model to predict house prices using Databricks, and you want to manually log parameters, models, and evaluation metrics using MLflow. After training the model, you decide to log the learning rate used for training, the trained model itself, and the RMSE (Root Mean Squared Error) of the model predictions. Which of the following MLflow methods should you use to accomplish this?
- A
mlflow.log_param('learning_rate', learning_rate_value)
- B
mlflow.log_metric('rmse', rmse_value)
- C
mlflow.log_artifact('trained_model.pkl')
- D
mlflow.log_model(trained_model, 'model_directory')
- E
mlflow.log_dataset('training_data', training_data)
Show answer and explanation
Correct answers: A, B, D
Explanation
To manually log parameters, metrics, and models using MLflow, you should use the appropriate logging methods: mlflow.log_param for parameters like learning rate, mlflow.log_metric for evaluation metrics like RMSE, and mlflow.log_model for saving the trained model. The other options either refer to non-existent methods or are not suitable for this specific scenario.
- A. Correct.
Correct. The mlflow.log_param method is used to log key-value pairs of parameters, such as the learning rate used during training.
- B. Correct.
Correct. The mlflow.log_metric method is used to log evaluation metrics, such as RMSE, which is a numerical evaluation score.
- C. Incorrect.
Incorrect. The mlflow.log_artifact method is used to log files or directories, but it is not directly applicable for logging models or metrics.
- D. Correct.
Correct. The mlflow.log_model method is used to log a trained machine learning model, along with its associated metadata, to MLflow.
- E. Incorrect.
Incorrect. The mlflow.log_dataset method does not exist in MLflow. Logging datasets is not directly supported by MLflow in this manner.