<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to display SHAP plots? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28320#M20143</link>
    <description>&lt;P&gt;As @Vinh dqvinh87​&amp;nbsp; noted, the accepted solution only works for &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;force_plot&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;. For other plots, the following trick works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import matplotlib.pyplot as plt
p = shap.summary_plot(shap_values, test_df, show=False) 
display(p)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2020 16:07:29 GMT</pubDate>
    <dc:creator>lrnzcig</dc:creator>
    <dc:date>2020-02-05T16:07:29Z</dc:date>
    <item>
      <title>How to display SHAP plots?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28315#M20138</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I am looking to display SHAP plots, here is the code:&lt;/P&gt;import xgboost import shap
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;shap.initjs() # load JS visualization code to notebookX,y = shap.datasets.boston() # train XGBoost model&lt;/P&gt; 
&lt;P&gt;model = xgboost.train({"learning_rate": 0.01}, xgboost.DMatrix(X, label=y), 100)&lt;/P&gt; 
&lt;P&gt;explainer = shap.TreeExplainer(model) # explain the model's predictions using SHAP values&lt;/P&gt; 
&lt;P&gt;shap_values = explainer.shap_values(X)&lt;/P&gt; 
&lt;P&gt;shap_explain = shap.force_plot(explainer.expected_value, shap_values[0,:], X.iloc[0,:]) # visualize the first prediction's explanation&lt;/P&gt; 
&lt;P&gt;displayHTML(shap_explain.data) # display plot&lt;/P&gt;
&lt;P&gt;However I am receiving the following error:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0693f000007OoIfAAK"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2524i77FE72F30F8371CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="0693f000007OoIfAAK" alt="0693f000007OoIfAAK" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any help greatly appreciated!&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 19:29:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28315#M20138</guid>
      <dc:creator>ArielHerrera</dc:creator>
      <dc:date>2019-02-13T19:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to display SHAP plots?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28316#M20139</link>
      <description>&lt;P&gt; I was finally able to plot them in DataBricks without js&lt;/P&gt;&lt;P&gt;&lt;/P&gt; shap_display = shap.force_plot(explainer.expected_value[1], shap_value[1], feat_x.iloc[0, :], matplotlib=True) 
&lt;P&gt;display(shap_display)&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 06:26:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28316#M20139</guid>
      <dc:creator>RimmaShafikova</dc:creator>
      <dc:date>2019-02-18T06:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to display SHAP plots?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28317#M20140</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;It also needs to be run on an earlier version of matplotlib&lt;/P&gt;
&lt;P&gt;matplotlib: 1.5.3&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 15:27:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28317#M20140</guid>
      <dc:creator>ArielHerrera</dc:creator>
      <dc:date>2019-02-21T15:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to display SHAP plots?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28318#M20141</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;For what it's worth, I got force plots to work in Databricks by copying the bundle.js Javascript from the SHAP package into a hidden cell in the notebook. See &lt;A href="https://databricks.com/blog/2019/06/17/detecting-bias-with-shap.html" target="test_blank"&gt;https://databricks.com/blog/2019/06/17/detecting-bias-with-shap.html&lt;/A&gt; and the notebook that accompanies it.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 01:21:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28318#M20141</guid>
      <dc:creator>sean_owen</dc:creator>
      <dc:date>2019-06-19T01:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to display SHAP plots?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28319#M20142</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;It is quite good but only works for a single explanation. If you want to apply to multiple samples, force_plot has not been supported yet as in Jan 2020.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 06:23:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28319#M20142</guid>
      <dc:creator>Vinhdqvinh87</dc:creator>
      <dc:date>2020-01-07T06:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to display SHAP plots?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28320#M20143</link>
      <description>&lt;P&gt;As @Vinh dqvinh87​&amp;nbsp; noted, the accepted solution only works for &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;force_plot&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;. For other plots, the following trick works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import matplotlib.pyplot as plt
p = shap.summary_plot(shap_values, test_df, show=False) 
display(p)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 16:07:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-display-shap-plots/m-p/28320#M20143</guid>
      <dc:creator>lrnzcig</dc:creator>
      <dc:date>2020-02-05T16:07:29Z</dc:date>
    </item>
  </channel>
</rss>

