Databricks Certified Machine Learning Associate · Free Practice Question Medium
Question 11
A senior data scientist is working on a machine learning project using MLflow. They want to implement a feature that allows for model explanations and interpretability.
Which MLflow component or library should they use for model interpretation?
-
A
mlflow.tensorflow -
B
mlflow.sklearn -
C
mlflow.shap -
D
mlflow.pytorch
Reveal correct answer
Correct answer: C
Explanation
Correct Answer:
mlflow.shap
Explanation:
Why This Is Correct?
mlflow.shapis MLflow’s built-in integration with SHAP (SHapley Additive exPlanations), a leading library for model interpretability. It:Generates feature importance scores (global interpretability).
Produces local explanations (per-prediction reasoning).
Logs visualizations (e.g., force plots, summary plots) as MLflow artifacts.
Example:
- import mlflow.shap
- import shap
- # Train model
- model = train_model(X_train, y_train)
- # Log SHAP summary
- explainer = shap.Explainer(model)
- shap_values = explainer(X_test)
- mlflow.shap.log_explanation(explainer, X_test)
Key Features:
Unified Tracking: SHAP outputs appear in the MLflow UI under the run’s artifacts.
Model-Agnostic: Works with sklearn, PyTorch, TensorFlow, etc.
Why Other Options Are Incorrect?
mlflow.sklearn/mlflow.pytorch/mlflow.tensorflow:These log models and metrics, but not explanations.
Key Takeaway:
For model interpretability in MLflow:
Use
mlflow.shapfor SHAP-based explanations.For non-SHAP methods (e.g., LIME), log custom plots via
mlflow.log_artifact().
Pro Tip: Compare explanations across runs using MLflow’s artifact diff view.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
