<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Soundarya Devi on Medium]]></title>
        <description><![CDATA[Stories by Soundarya Devi on Medium]]></description>
        <link>https://medium.com/@soundaryadevi1998?source=rss-37e681766bb3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ziC0cVItDtYlTfpt.jpg</url>
            <title>Stories by Soundarya Devi on Medium</title>
            <link>https://medium.com/@soundaryadevi1998?source=rss-37e681766bb3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:22:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soundaryadevi1998/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Model Explainability: From Black Box to Transparency ML Models using SHAP]]></title>
            <link>https://medium.com/@soundaryadevi1998/model-explainability-from-black-box-to-transparency-ml-models-using-shap-2e2337337de6?source=rss-37e681766bb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e2337337de6</guid>
            <category><![CDATA[shap]]></category>
            <category><![CDATA[model-explainability]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Soundarya Devi]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 14:00:55 GMT</pubDate>
            <atom:updated>2024-12-24T16:00:37.448Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine learning powers countless decisions today, but understanding its inner workings is vital to ensure fairness and trust. This article explores the importance of explainability in machine learning, focusing on SHAP values, a powerful tool to decode model predictions and reveal feature contributions.</p><h3><strong>What is machine learning in </strong>layman<strong> terms?</strong></h3><p>Machine learning is the mathematical method that uses feed data to predict the value of unknown variable. The prediction quality depends on the quality of the data fed into the system. This mathematical method that learns from data is what we call a model. Even if a model’s predictions seem accurate, how can we ensure it learned without any inherent bias? If bias exists, how can we detect it? This is where explainability becomes crucial. Bias detection relies on explainability, as it enables us to identify the root causes of unfair decisions.</p><h3><strong>Model explainability</strong></h3><p>Consider a problem statement: eligibility check for a credit card. A model is trained with historical data that mainly consists of a male population. If this trained model rejects all female applications and we implement this model in real life without understanding its inner workings, it could lead to huge issues. For instance, the bank may be seen as biased based on gender. Hence, model explainability is crucial, particularly in sensitive use cases such as finance and health (e.g., diagnostic tests). Now that we understand the need for model explainability, let’s delve deeper into its essence.</p><p>Model explainability means that you can explain what happens in your model from input to output. It makes models transparent and solves the black box problem.</p><p>There are different explainability techniques that can be used based on the needed scope (<strong>Local </strong>— explain predictions for specific data points; <strong>Global — </strong>explain overall dataset predictions) and the type of model we are trying to explain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*GD7U-FV7eYw_tXGsR3qhVA.png" /><figcaption>Created by the Author</figcaption></figure><p>Techniques for Explainability</p><ul><li>Interpretable Models like Linear Regression, Decision Trees</li><li>Partial Dependence Plots (PDP)</li><li>Individual Conditional Expectations Plots (ICE)</li><li>Leave One Column Out (LOCO)</li><li>LIME</li><li>SHAP</li></ul><p>Each technique has its advantages and use cases. In this article, we will focus on SHAP in detail.</p><h3>SHAP</h3><p>SHAP (SHapley Additive exPlanations) is a method to explain predictions. SHAP is based on the game-theoretically optimal Shapley values.</p><p>A prediction can be explained by assuming that each feature value of the instance is a “player” in a game where the prediction is the payout. Shapley values — a method from coalitional game theory — tell us how to fairly distribute the “payout” among the features. The Shapley value is the average marginal contribution of a feature value across all possible coalitions.</p><p>Calculation:</p><ul><li>Baseline Value: Start with the average prediction across the dataset (expected value).</li><li>Feature Permutation: Consider all possible subsets of features.</li><li>Model Prediction Adjustment: Compare predictions with and without each feature to compute its impact.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lj8MJ4Nt5455YqUWEXbgow.png" /></figure><p>Shapley values require evaluating all feature subsets, making them computationally intensive. SHAP uses approximation techniques to compute feature contributions efficiently. It employs techniques like Kernel SHAP and Tree SHAP to approximate Shapley values efficiently without needing to evaluate all feature subsets.</p><p>Let’s understand how it works with a toy example and construct a <strong>decision tree</strong>. We will still compute SHAP values and demonstrate how the contributions are calculated efficiently using <strong>Tree SHAP</strong>.</p><h4>Dataset</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GbJo6-6WL3nRrZMk-_Od5w.png" /></figure><h4>Decision Tree Structure</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*iOE2x_uCSxH74kfK-VjETQ.png" /></figure><h3>Instances to Explain</h3><h4>Instance 1: x = 150, y = 75, z = 200</h4><p>The model predicts <strong>50</strong> for this instance based on the following path:</p><ul><li><strong>Root Split</strong>: x = 150 ⇒ x&gt;125</li><li><strong>Second Split</strong>: y = 75 ⇒ y&gt;60</li><li><strong>Third Split</strong>: z = 200 ⇒ z&gt;180 ⇒ Prediction = 50</li></ul><p>Computing SHAP Values for instance</p><h4>Baseline (Expected Value)</h4><p>The baseline is the average prediction over all training samples:</p><p>Baseline= (15+30+40+10+25+35+50+15+60+45) / 10=32.5</p><h4><strong>Path Contributions</strong></h4><p><strong>a. Root Node Contribution (x)</strong>:</p><p>Without knowing x, the prediction is the baseline: 32.5</p><ul><li>Knowing x &gt; 125, the prediction moves to the next split, where the average prediction for x &gt; 125 is (20+30+50)/3 = 33.33</li><li>Contribution of x : 33.33−32.5 = +0.83</li></ul><p><strong>b. Second Split Contribution (y)</strong>:</p><ul><li>Knowing y &gt; 60, the prediction moves to the next split, where the average prediction for x &gt; 125 and y &gt; 60 is (30+50)/2=40.</li><li>Contribution of y: 40−33.33=+6.67</li></ul><p><strong>c. Third Split Contribution (z)</strong>:</p><ul><li>Knowing z &gt; 180, the prediction moves to the final leaf with t=50</li><li>Contribution of z: 50−40=+10.</li></ul><h4><strong>Final SHAP Values</strong></h4><p>Total Contribution: 32.5 + 0.83 + 6.67 + 10 = 50 (matches the prediction).<br>so for this instance x = 150, y = 75, z = 200 starting from the baseline prediction of <strong>32.5</strong>, the feature <strong>x</strong> contributed <strong>+0.83</strong>, <strong>y</strong> contributed <strong>+6.67</strong>, and <strong>z</strong> contributed <strong>+10.0</strong>, bringing the total prediction to <strong>50.</strong></p><h4><strong>Instance 2: x = 100, y = 40, z = 100</strong></h4><p>The model predicts 15 for this instance based on the following path:</p><p><strong>Root Split</strong>: x=100 ⇒ x ≤ 125 ⇒ Prediction = 15</p><p><strong>Baseline (Expected Value)</strong>: same 32.5</p><p><strong>Path contribution:</strong></p><p>Let’s compute the SHAP contributions for this instance:<br><strong>a. Root Node Contribution (x)</strong>:</p><ul><li>Without knowing x, the prediction is the baseline: <strong>32.5</strong></li><li>Knowing x=100, which leads to the left branch (since 100≤125), the prediction is <strong>15</strong>.</li><li>Contribution of x: 15−32.5 = <strong>−17.5</strong>.</li></ul><p><strong>b. Second Split Contribution (y)</strong>:<br> The prediction remains <strong>15</strong>, because there is no further split in the tree when x ≤ 125 (as we already reached the leaf).<br>Contribution of y: <strong>0 </strong>(since y does not affect the prediction here)</p><p><strong>c. Third Split Contribution (z)</strong>:<br>Similar to y, the prediction remains <strong>15</strong> since the path has already ended at the leaf node. <br>Contribution of z: <strong>0</strong> (since z does not affect the prediction here).</p><h4>Final SHAP Values</h4><p>Total Contribution: 32.5 -17.5 + 0 + 0 = 15 (matches the prediction).<br>so for this instance x = 100, y = 40, z = 100 starting from the baseline prediction of <strong>32.5</strong>, the feature <strong>x</strong> contributed <strong>−17.5</strong>, while <strong>y</strong> and <strong>z</strong> contributed <strong>0</strong> each, reducing the total prediction to <strong>15.</strong></p><h4>Why Tree SHAP is More Efficient?</h4><p>In <strong>Shapley calculations, </strong>for each feature, we need to calculate the prediction for every possible ordering of the features. This means computing the prediction for all possible subsets of features and evaluating the impact of each feature by comparing the difference in predictions between these subsets where as <strong>Tree SHAP</strong> exploits the decision tree structure by reducing the problem to traversing the tree and evaluating only the relevant splits and nodes.</p><h3>SHAP Feature Importance</h3><ul><li>Local Explanation: SHAP values provide a local explanation for each prediction, indicating how features influence individual predictions.</li><li>Global Interpretation: Idea behind SHAP feature importance is simple, features with large absolute Shapley values are important. Since we want the global importance, we average the <strong>absolute</strong> Shapley values per feature across the data:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wS0X7RhtFOQHpGsAWbifg.png" /></figure><h3>Conclusion</h3><p>Model explainability bridges the gap between complex machine learning models and real-world applications by ensuring transparency, fairness, and trust. Techniques like SHAP empower data scientists to decode the “why” behind predictions, enabling responsible and impactful AI solutions. By integrating explainability into machine learning workflows, we can build systems that not only perform exceptionally well but also gain the trust and confidence of users and stakeholders</p><h3>Resources</h3><p><a href="https://christophm.github.io/interpretable-ml-book/">Interpretable Machine Learning</a></p><p><a href="https://neptune.ai/blog/explainability-auditability-ml-definitions-techniques-tools?utm_source=linkedin&amp;utm_medium=post&amp;utm_campaign=blog-explainability-auditability-ml-definitions-techniques-tools">https://neptune.ai/blog/explainability-auditability-ml-definitions-techniques-tools</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e2337337de6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>