Databricks Machine Learning Associate Question 103
Single answerYou are training a machine learning model and want to manually log the model’s accuracy, the training data as an artifact, and the trained model itself in an MLflow Run. Which sequence of actions is the most appropriate to achieve this?
- A
Start an MLflow run, use
mlflow.log_metricto log the accuracy,mlflow.log_artifactto log the training data, andmlflow.sklearn.log_modelto log the trained model. - B
Start an MLflow run, use
mlflow.log_paramto log the accuracy,mlflow.log_artifactsto log the training data, andmlflow.pyfunc.log_modelto log the trained model. - C
Start an MLflow run, use
mlflow.log_metricto log the accuracy,mlflow.log_artifactsto log the training data, andmlflow.log_modelto log the trained model. - D
Start an MLflow run, use
mlflow.log_metricto log the accuracy,mlflow.log_artifactto log the training data, andmlflow.log_paramsto log the trained model.
Show answer and explanation
Correct answer: A
Explanation
To manually log metrics, artifacts, and models in MLflow, you need to use the correct functions for each task. mlflow.log_metric is used for logging numerical metrics, mlflow.log_artifact is for logging single files, and mlflow.sklearn.log_model is specifically designed for logging scikit-learn models. Ensuring that each function is used appropriately is essential for effectively tracking your machine learning experiments.
- A. Correct.
This is the correct option.
mlflow.log_metricis used to log numerical metrics like accuracy,mlflow.log_artifactis for logging a single file (e.g., the training data), andmlflow.sklearn.log_modelis appropriate for logging models trained using scikit-learn. - B. Incorrect.
mlflow.log_paramis used for logging parameters (key-value pairs), not metrics like accuracy, making this option incorrect. - C. Incorrect.
mlflow.log_artifactsis used to log multiple files or a directory, not a single file like the training data in this scenario, making this option incorrect. - D. Incorrect.
mlflow.log_paramsis used for logging parameters (key-value pairs), not models, making this option incorrect.