Databricks Machine Learning Associate Question 461
Select 3You are training a machine learning model in Databricks and want to manually log custom metrics, artifacts, and the model itself during an MLflow run. Which of the following steps are necessary to achieve this?
- A
Start an MLflow run using mlflow.start_run() before logging any metrics or artifacts.
- B
Use mlflow.log_metric() to log custom metrics during the training process.
- C
Invoke mlflow.log_artifact() to log files such as a confusion matrix image or training data used for the model.
- D
Call mlflow.register_model() to save the model to an MLflow experiment.
- E
Ensure that the MLflow tracking URI is set to 'databricks' using mlflow.set_tracking_uri('databricks').
Show answer and explanation
Correct answers: A, B, C
Explanation
To manually log metrics, artifacts, and models during an MLflow run in Databricks, you must first start an MLflow run using mlflow.start_run(). Then, you can log custom metrics with mlflow.log_metric() and artifacts with mlflow.log_artifact(). Registering a model or setting the MLflow tracking URI is not a requirement for these manual logging operations, making only options 1, 2, and 3 correct.
- A. Correct.
Correct. Starting an MLflow run using mlflow.start_run() is mandatory to log any metrics, artifacts, or models to the MLflow tracking server.
- B. Correct.
Correct. mlflow.log_metric() is the function used to log custom metrics, such as accuracy or loss, during the training process.
- C. Correct.
Correct. mlflow.log_artifact() is used to log files, such as images or datasets, as artifacts in the MLflow experiment.
- D. Incorrect.
Incorrect. mlflow.register_model() is used to register a model to the MLflow Model Registry, but it is not required for logging metrics and artifacts in an MLflow run.
- E. Incorrect.
Incorrect. While setting the MLflow tracking URI to 'databricks' is helpful for ensuring logging to Databricks' MLflow tracking server, it is not mandatory for manual logging of metrics, artifacts, and models during an MLflow run.