Hi @invalidargument , To display the SHAP waterfall plot in Databricks, you can use the display()
function to show the plot in the Databricks Notebook.
Here's an example:
import shap
import pandas as pd
explainer = shap.Explainer(model)
shap_values = explainer(data)
# Create the waterfall plot and show it using display()
shap.plots.waterfall(shap_values[0])
display()
The display()
function can display a wide range of data types including Pandas DataFrames, Matplotlib figures, and HTML.
Make sure that you are importing the display()
function from Databricks and not the IPython.display()
function so that it works correctly in Databricks.
Also, make sure that you are running your code in a Databricks Notebook with mlflow.shap.autolog()
or mlflow.shap.log_explanation()
before calling the waterfall()
method. This ensures that SHAP values are available for the plot.