Databricks Machine Learning Professional Question 48
Select 3You are training a machine learning model in a Databricks notebook and want to log SHAP plots, custom visualizations, and metadata for your experiment runs. Which of the following steps should you take to properly log and view these artifacts using MLflow in Databricks?
- A
Use the
mlflow.log_artifact()function to log SHAP plots and other custom visualizations. - B
Save the SHAP plot or visualization as a file (e.g., PNG or HTML) locally before logging it as an artifact.
- C
Directly pass a Python object representing the SHAP plot to
mlflow.log_artifact(). - D
Use the MLflow UI in Databricks to view logged artifacts after the run is complete.
- E
Enable automatic artifact logging in MLflow to log SHAP plots and custom visualizations without any additional code.
Show answer and explanation
Correct answers: A, B, D
Explanation
To log and view artifacts like SHAP plots and custom visualizations in MLflow on Databricks, you must save the visualizations as files locally and then log them using mlflow.log_artifact(). Once logged, you can view these artifacts in the MLflow UI after the experiment run. Automatic artifact logging cannot handle custom visualizations, so explicit logging is necessary.
- A. Correct.
Correct: The
mlflow.log_artifact()function is the standard way to log artifacts such as SHAP plots, custom visualizations, or any other files in MLflow. This makes the artifacts accessible in the MLflow tracking UI. - B. Correct.
Correct: Since
mlflow.log_artifact()requires a file path as input, you must save the SHAP plot or visualization as a file (e.g., PNG, HTML, etc.) before logging it. - C. Incorrect.
Incorrect: You cannot directly pass a Python object (e.g., a SHAP plot object) to
mlflow.log_artifact(). The method requires a file path pointing to the artifact. - D. Correct.
Correct: The MLflow UI in Databricks provides a convenient way to view logged artifacts after an experiment run is completed.
- E. Incorrect.
Incorrect: Automatic artifact logging is not supported for custom visualizations or SHAP plots. These artifacts must be explicitly logged using code.