Databricks Machine Learning Professional Question 49
Select 3As a data scientist, you are training a machine learning model in Databricks and want to log and visualize important artifacts such as SHAP plots, a custom confusion matrix image, and metadata about feature importance. Which of the following steps should you take to properly log and view these artifacts using MLflow?
- A
Use
mlflow.log_artifact()to log the SHAP plot, confusion matrix image, and feature importance metadata. - B
Use
mlflow.log_figure()to directly log the SHAP plot and confusion matrix image if they are matplotlib figures. - C
Use
mlflow.log_param()to log the SHAP plot and confusion matrix image. - D
Store the confusion matrix image and SHAP plot as files and use
mlflow.log_artifact()to log them. - E
Log feature importance metadata as a dictionary using
mlflow.log_dict().
Show answer and explanation
Correct answers: B, D, E
Explanation
To properly log and visualize artifacts such as SHAP plots, confusion matrix images, and feature importance metadata in Databricks using MLflow, you need to use the appropriate MLflow functions for each type of artifact. mlflow.log_figure() is ideal for directly logging visualizations as matplotlib figures, mlflow.log_artifact() is used for files stored on disk, and mlflow.log_dict() is suitable for structured metadata like feature importance. Understanding and choosing the correct method ensures that artifacts are logged and visualized effectively.
- A. Incorrect.
Incorrect:
mlflow.log_artifact()is used to log files such as images or other data stored on disk, but it is not the best method for directly logging a SHAP plot or matplotlib figures. - B. Correct.
Correct:
mlflow.log_figure()is specifically designed to log matplotlib figures or similar visualizations directly without needing to save them as files first. - C. Incorrect.
Incorrect:
mlflow.log_param()is used to log parameters (key-value pairs) but cannot handle visualizations like SHAP plots or confusion matrix images. - D. Correct.
Correct: If the SHAP plot or confusion matrix image is stored as a file (e.g., PNG),
mlflow.log_artifact()is an appropriate method to log these types of files. - E. Correct.
Correct: Feature importance metadata can be logged as a dictionary using
mlflow.log_dict(), which is well-suited for structured data like JSON or dictionaries.