<?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: Shap Values for predictions from registered model in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33241#M1756</link>
    <description>&lt;P&gt;Yes, TreeExplainer only works on the tree-based model itself. That's fine and the way to use it if you literally only want to explain the model, not the pipeline. If you want to explain anything else like a PIpeline or custom pyfunc model, you need to use KernelExplainer in SHAP (think it's just called Explainer now, yes). It's much slower but can operate on anything.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2022 22:36:30 GMT</pubDate>
    <dc:creator>sean_owen</dc:creator>
    <dc:date>2022-09-19T22:36:30Z</dc:date>
    <item>
      <title>Shap Values for predictions from registered model</title>
      <link>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33238#M1753</link>
      <description>&lt;P&gt;I have saved a model in the model registry using MLFlow.&amp;nbsp;How can I find the shap values for this model once I have generated predictions in batch mode?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shap tree explainer does not support the mlflow pyfunc model type.  When I use mlflow.shap.log_explanation(model.predict, data), I get an error that Provided model function fails when applied to the provided data set.   It seems to indicate the required columns are missing.  All the required columns were included and when I run predictions with the model it generates predictions.  model.predict(data).  &lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 17:16:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33238#M1753</guid>
      <dc:creator>Evan_MCK</dc:creator>
      <dc:date>2022-08-29T17:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shap Values for predictions from registered model</title>
      <link>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33240#M1755</link>
      <description>&lt;P&gt;Thanks for your help. I was able to figure it out from the documentation but adjustments were needed. The model which was based on the Data Bricks auto ML model was really an sk learn pipeline. I have no y values as this is prediction data, not a test set. I needed to use the mlflow sklearn model.  &lt;/P&gt;&lt;P&gt;model = mlflow.sklearn.load_model(model_uri)&lt;/P&gt;&lt;P&gt;For Shap tree explainer (shown in the documentation) I needed to use the tree explainer as the model in the pipeline and manually run the other parts of the pipeline. Like this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;explainer = shap.TreeExplainer(model['regressor'])&lt;/P&gt;&lt;P&gt;observations = model["column_selector"].transform(prediction_data)&lt;/P&gt;&lt;P&gt;observations = model["standardizer"].transform(observations)&lt;/P&gt;&lt;P&gt;shap_values = explainer.shap_values(observations)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option was not to use the tree explainer: see: &lt;A href="https://towardsdatascience.com/using-shap-values-to-explain-how-your-machine-learning-model-works-732b3f40e137" alt="https://towardsdatascience.com/using-shap-values-to-explain-how-your-machine-learning-model-works-732b3f40e137" target="_blank"&gt;https://towardsdatascience.com/using-shap-values-to-explain-how-your-machine-learning-model-works-732b3f40e137&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;explainer = shap.Explainer(model.predict, prediction_data)&lt;/P&gt;&lt;P&gt;shap_values = explainer(prediction_data, max_evals = 2000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 16:27:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33240#M1755</guid>
      <dc:creator>Evan_MCK</dc:creator>
      <dc:date>2022-08-30T16:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shap Values for predictions from registered model</title>
      <link>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33241#M1756</link>
      <description>&lt;P&gt;Yes, TreeExplainer only works on the tree-based model itself. That's fine and the way to use it if you literally only want to explain the model, not the pipeline. If you want to explain anything else like a PIpeline or custom pyfunc model, you need to use KernelExplainer in SHAP (think it's just called Explainer now, yes). It's much slower but can operate on anything.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 22:36:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33241#M1756</guid>
      <dc:creator>sean_owen</dc:creator>
      <dc:date>2022-09-19T22:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shap Values for predictions from registered model</title>
      <link>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33239#M1754</link>
      <description>&lt;P&gt;Hi, Could you please check if this section helps in the below documentation:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.databricks.com/blog/2019/06/17/detecting-bias-with-shap.html" target="test_blank"&gt;https://www.databricks.com/blog/2019/06/17/detecting-bias-with-shap.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1560iBBE3D36D55E63ED8/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:48:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/shap-values-for-predictions-from-registered-model/m-p/33239#M1754</guid>
      <dc:creator>Debayan</dc:creator>
      <dc:date>2022-08-30T12:48:24Z</dc:date>
    </item>
  </channel>
</rss>

