{"id":264544,"date":"2026-07-15T02:13:17","date_gmt":"2026-07-14T23:13:17","guid":{"rendered":"https:\/\/1kitap1.com\/en\/interpreting-machine-learning-models-shap-christoph-molnar\/"},"modified":"2026-07-15T02:13:17","modified_gmt":"2026-07-14T23:13:17","slug":"interpreting-machine-learning-models-shap-christoph-molnar","status":"publish","type":"post","link":"https:\/\/1kitap1.com\/en\/interpreting-machine-learning-models-shap-christoph-molnar\/","title":{"rendered":"Interpreting Machine Learning Models SHAP &#8211; Christoph Molnar"},"content":{"rendered":"<figure style=\"text-align:center;margin:0 auto 1.5em;\"><img decoding=\"async\" src=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/c5638a823a9067eb.jpg\" alt=\" - Unknown book cover\" style=\"max-width:300px;width:100%;height:auto;box-shadow:0 4px 12px rgba(0,0,0,.25);border-radius:4px;\"\/><\/figure>\n<p>There are two \u201clines\u201d: One line represents fans who are >7 away from the stage (x2). Here we see the large jump, which is expected since fans taller than 160cm have no chance of getting on someone\u2019s shoulders. The other line represents values of x2 below 7. It has a smaller jump, but why is there a jump at all? Fans in this \u201ccluster\u201d don\u2019t get to sit on someone\u2019s shoulders when they are smaller than 160cm.<\/p>\n<p>The reason why the interaction also \u201cbleeds\u201d into the cluster where we wouldn\u2019t expect it has to do with how SHAP values function. 10.3 SHAP values have a \u201cglobal\u201d component Let\u2019s consider two fans: 1. Mia, who is 159cm tall and 2 units away from the stage. 2. Tom, who is 161cm tall and standing right next to Mia, also 2 units away from the stage. Here are the model\u2019s predictions for how much they will enjoy the concert: Mia: 5.88 # Creating data for Mia and Tom Xnew = pd.DataFrame({&#8216;x1&#8217;: [159, 161], &#8216;x2&#8217;: [2,2]}) print(&#8220;&#8221;&#8221; Mia: {mia} Tom: {tom} Expected: {exp} &#8220;&#8221;&#8221;.format( mia=round(rf_model.predict(Xnew)[0], 2), tom=round(rf_model.predict(Xnew)[1], 2), exp=round(explainer.expected_value[0], 2) )) Tom: 6.07 Expected: 4.86 They have a rather similar predicted joy for the concert, with Mia having a slightly worse prediction \u2013 makes sense given she is slightly smaller and neither of them qualify for shoulders.<\/p>\n<p>Let\u2019s examine their SHAP values. Mia [-0.15944093 1.18150926] Tom [-1.37794848 2.5913748 ] The SHAP values for Mia and Tom differ significantly. Mia\u2019s slightly negative value for height is understandable, given her relative shortness compared to the majority of simulated heights. Mia\u2019s positive SHAP value for distance makes sense as she is quite near the front. Tom\u2019s SHAP values follow similar trends, which is expected since they share the same distance and similar heights.<\/p>\n<p>However, Tom\u2019s SHAP values are more pronounced. But shouldn\u2019t Mia have a smaller SHAP value for height than Tom? Neither of them benefits from the shoulder bonus, so Mia being smaller than Tom should mean that her SHAP value for \u201cheight\u201d should be smaller than Tom\u2019s, right?<\/p>\n<p>But surprisingly, Mia\u2019s SHAP value is influenced by the interaction term, despite her not being directly affected by the shoulder bonus!<\/p>\n<blockquote>\n<p>In my first book, \u201cInterpretable Machine Learning,\u201d I overlooked the inclusion of SHAP. I conducted a Twitter survey to determine the most frequently used methods for interpreting machine learning models. Options included LIME, permutation feature importance, partial dependence plots, and \u201cOther.\u201d SHAP was not an option.<\/p>\n<p>To my surprise, the majority of respondents selected \u201cOther,\u201d with many comments highlighting the absence of SHAP. Although I was aware of SHAP at that time, I underestimated its popularity in machine learning explainability. This popularity was a double-edged sword. My PhD research on interpretable machine learning was centered around partial dependence plots and permutation feature importance. On multiple occasions, when submitting a paper to a conference, we were advised to focus on SHAP or LIME instead.<\/p>\n<p>This advice was misguided because we should make progress for all interpretation methods, not just SHAP, but it underscores the popularity of SHAP. SHAP has been subjected to its fair share of criticism: it\u2019s costly to compute, challenging to interpret, and overhyped. I agree with some of these criticisms. In the realm of interpretable machine learning, there\u2019s no perfect method; we must learn to work within constraints, which this book also addresses. However, SHAP excels in many areas: it can work with any model, it\u2019s modular in building global interpretations, and it has a vast ecosystem of SHAP adaptations.<\/p>\n<p>As you can see, my relationship with SHAP is a mix of admiration and frustration \u2013 perhaps a balanced standpoint for writing about SHAP. I don\u2019t intend to overhype it, but I believe it\u2019s a beneficial tool worth understanding. OceanofPDF.com 2 Introduction Machine learning models are powerful tools, but their lack of interpretability is a challenge.<\/p>\n<p>It\u2019s often unclear why a certain prediction was made, what the most important features were, and how the features influenced the predictions in general. Many people argue that as long as a machine learning model performs well, interpretability is unnecessary. However, there are many practical reasons why you need interpretability, ranging from debugging to building trust in your model. I think of \u201cinterpretability\u201d in the context of machine learning as a keyword.<\/p>\n<p>Under this keyword, you find a colorful variety of approaches that attempt to extract information about how the model makes predictions. 2.1 Interpreting to debug Interpretability is valuable for model debugging, as illustrated by a study predicting pneumonia (Caruana et al. 2015). The authors trained a rule- based model, which learned that if a patient has asthma, they have a lower risk of pneumonia.<\/p>\n<p>Seriously?<\/p>\n<\/blockquote>\n<p><em>This is a short excerpt from the opening of &ldquo;&rdquo; by Unknown, quoted for review and introduction purposes. All rights belong to the copyright holders.<\/em><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/1kitap1.com\/en\/interpreting-machine-learning-models-shap-christoph-molnar\/#Book_Information\" >Book Information<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/1kitap1.com\/en\/interpreting-machine-learning-models-shap-christoph-molnar\/#Reading_Word_Statistics\" >Reading &amp; Word Statistics<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/1kitap1.com\/en\/interpreting-machine-learning-models-shap-christoph-molnar\/#Most_Frequent_Words\" >Most Frequent Words<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/1kitap1.com\/en\/interpreting-machine-learning-models-shap-christoph-molnar\/#PDF_Download\" >PDF Download<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Book_Information\"><\/span>Book Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Unique ID:<\/strong> c5638a823a9067eb<\/li>\n<li><strong>File Extension:<\/strong> .pdf<\/li>\n<li><strong>File Size:<\/strong> 8,162,973 bytes (7.785 MB)<\/li>\n<li><strong>Title:<\/strong> &#8211;<\/li>\n<li><strong>Author:<\/strong> Unknown<\/li>\n<li><strong>Pages:<\/strong> 221<\/li>\n<li><strong>Language:<\/strong> English (en)<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Reading_Word_Statistics\"><\/span>Reading &amp; Word Statistics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Estimated Reading Time:<\/strong> 189.59 minutes<\/li>\n<li><strong>Total Words:<\/strong> 37,918<\/li>\n<li><strong>Total Characters:<\/strong> 246,733<\/li>\n<li><strong>Average Words per Page:<\/strong> 171.57<\/li>\n<li><strong>Average Characters per Page:<\/strong> 1116.44<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Most_Frequent_Words\"><\/span>Most Frequent Words<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>shap (840), values (575), model (334), data (298), feature (271), features (224), value (184), prediction (155), explainer (140), shapley (131), models (113), linear (110), learning (104), plot (104), machine (100), marginal (91), test (89), use (88), method (84), train (80), however (78), let\u2019s (78), also (77), background (77), alcohol (76), one (74), using (74), import (74), estimator (73), sampling (72), coalition (72), coalitions (72), image (71), example (71), function (69), two (64), chapter (64), predictions (62), contribution (62), correlation (61), plots (59), regression (59), text (58), instance (58), contributions (58), based (57), input (57), masker (57), tree (56), between (54), bob (54), random (53), plt (53), permutation (52), alice (52), interpretation (51), explanations (49), estimation (49), it\u2019s (48), point (48), mask (47), first (46), average (46), methods (45), importance (45), number (45), interactions (45), like (44), explanation (43), different (43), print (42), predicted (41), interaction (41), charlie (41), used (40), dataset (40), additive (40), now (38), classification (38), possible (38), taxi (38), wine (38), theory (37), neural (37), game (37), set (37), time (36), compute (36), individual (36), explain (36), wines (36), clustering (36), interpretable (35), gradient (35), expected (35), instead (34), deep (34), size (34), index (34), output (34).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"PDF_Download\"><\/span>PDF Download<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align:center;\"><a href=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/interpreting-machine-learning-models-shap-christoph-molnar.pdf\" download rel=\"nofollow\" style=\"display:inline-block;background:#2271b1;color:#ffffff;padding:14px 36px;border-radius:6px;text-decoration:none;font-weight:bold;font-size:1.05em;\">&#11015;&#65039; PDF Download<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two \u201clines\u201d: One line represents fans who are >7 away from the stage (x2). Here we see the large jump, which is expected since fans taller than 160cm have no chance of getting on someone\u2019s shoulders. The other line represents values of x2 below 7. It has a smaller jump, but why is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":264542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-264544","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-english"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/264544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/comments?post=264544"}],"version-history":[{"count":0,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/264544\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media\/264542"}],"wp:attachment":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media?parent=264544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/categories?post=264544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/tags?post=264544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}