cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to display shap waterfall plot

invalidargument
New Contributor III

Hi,

I have managed to display force plot for a single observation using the advice from this thread:

Solved: How to display SHAP plots? - Databricks - 28315

But is there anyway to display the newer "waterfall"-plot 

shap.plots.waterfall — SHAP latest documentation

When running

 

shap.plots.waterfall(shap_values[0])

 

 I get output like

 

Out[105]: <Figure size 576x468 with 3 Axes>

 

 I have tried calling:

  • plt.show()
  • display()
  • display(plt.gcf())

But same result. Any advice? Is it supposed to work?

1 REPLY 1

invalidargument
New Contributor III

Thank you for the swift response. 

I made a minimal example and it does work as you said. However when I try with my own model it does not work, the only output is

<Figure size 576x468 with 3 Axes>

I tried to save the figure as a file and then I do get a plot, but it does look a little broken. 

 

p = shap.plots.waterfall(shap_values[0],show=False)
p.savefig("plot.png")
 
My guess is that the plot shap outputs for my shap_values is broken,too large or has some other problem so databricks fails to render it.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group