{"id":7868,"date":"2023-10-06T15:02:10","date_gmt":"2023-10-06T23:02:10","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=7868"},"modified":"2025-04-24T17:05:43","modified_gmt":"2025-04-24T17:05:43","slug":"integrating-comet-with-shap-values","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/","title":{"rendered":"Integrating Comet with Shap Values"},"content":{"rendered":"\n<div class=\"fj fk fl fm fn\">\n<div class=\"ab ca\">\n<div class=\"ch bg ev ew ex ey\">\n<figure class=\"ms mt mu mv mw mx mp mq paragraph-image\">\n<div class=\"my mz ec na bg nb\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nc nd c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m\" alt=\"\" width=\"700\" height=\"467\"><\/figure><div class=\"mp mq mr\"><picture><\/picture><\/div>\n<\/div><figcaption class=\"ne nf ng mp mq nh ni be b bf z dw\" data-selectable-paragraph=\"\">Photo by <a class=\"af nj\" href=\"https:\/\/unsplash.com\/@christinhumephoto?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Christin Hume<\/a> on <a class=\"af nj\" href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Unsplash<\/a><\/figcaption><\/figure>\n<p id=\"b64a\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Sometimes when you build a Machine Learning model, the results produced differ from those expected, despite having appropriately taken all the necessary precautions (feature selection, model optimization, and so on). In these cases, you move on to the <strong class=\"be of\">troubleshooting phase<\/strong>, where, in addition to looking for any errors in the code, you can resort to so-called <strong>r<\/strong><strong class=\"be of\">everse engineering<\/strong>. Reverse engineering indicates starting with the results, and working backwards to try to understand how these results were produced.<\/p>\n<p id=\"675f\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">There are several techniques for performing reverse engineering in the Machine Learning sector. In this article, I describe one, based on the calculation of the<strong class=\"be of\"> Shapley value<\/strong>, a metric that describes the contribution of each input feature to an algorithm in producing the final result.<\/p>\n<p id=\"08c4\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">There is a Python library that implements the Shapley value calculation, and also produces some interesting graphs. In this article I show how to use this library and how to integrate it into Comet.<\/p>\n<p id=\"b3ba\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Find the official documentation <a class=\"af nj\" href=\"https:\/\/www.comet.com\/docs\/python-sdk\/shap\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">here.<\/a><\/p>\n<div class=\"og oh oi oj ok ol\">\n<div class=\"om ab it\">\n<div class=\"on ab cn ca oo op\"><\/div>\n<\/div>\n<\/div>\n<p id=\"9fa1\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">The article is organized as follows:<\/p>\n<ul class=\"\">\n<li id=\"0f6e\" class=\"nk nl fq be b gt nm nn no gw np nq nr ns ot nu nv nw ou ny nz oa ov oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">Quick overview of the Shapley Value<\/li>\n<li id=\"aa51\" class=\"nk nl fq be b gt oz nn no gw pa nq nr ns pb nu nv nw pc ny nz oa pd oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">A practical example<\/li>\n<\/ul>\n<h1 id=\"c5a1\" class=\"pe pf fq be pg ph pi gv pj pk pl gy pm pn po pp pq pr ps pt pu pv pw px py pz bj\" data-selectable-paragraph=\"\">1. Quick overview of the Shapley Value<\/h1>\n<p id=\"9e1a\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">SHAP stands for <em class=\"qf\">SHapley Additive exPlanations. <\/em>The concept of the Shapley value derives from <strong class=\"be of\">cooperative game theory<\/strong>, and it measures the contribution of each player to a game.<\/p>\n<p id=\"fb79\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">In Machine Learning, <strong class=\"be of\">a Shapley value measures the contribution of each input feature to the outcome, separately, as compared with all the other input features<\/strong>. In practice, a Shapely value permits understanding how a predicted value is built from the input features.<\/p>\n<p id=\"e5da\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">There is a Python library, named <code class=\"cw qg qh qi qj b\">shap<\/code>, which you can install through pip as follows:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"df34\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">pip install shap<\/span><\/pre>\n<p id=\"3e8d\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">The official documenation of the <code class=\"cw qg qh qi qj b\">shap<\/code> package is avalaible at <a class=\"af nj\" href=\"https:\/\/shap.readthedocs.io\/en\/latest\/index.html\" target=\"_blank\" rel=\"noopener ugc nofollow\">this link<\/a>.<\/p>\n<p id=\"6cff\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">To get started with the <code class=\"cw qg qh qi qj b\">shap<\/code> library, you should create an <code class=\"cw qg qh qi qj b\">Explainer<\/code> object, which receives as input a trained model:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"d216\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">import shap\nexplainer = shap.<strong class=\"qj ga\">Explainer<\/strong>(model.predict)<\/span><\/pre>\n<p id=\"4a5b\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Then, you can apply the created explainer to the dataset to test:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"728c\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">shap_values = explainer(X_test)<\/span><\/pre>\n<p id=\"262c\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">You can use the extracted shap values to plot different graphs, including summary plots, waterfall plots, and much more.<\/p>\n<h1 id=\"c2fc\" class=\"pe pf fq be pg ph pi gv pj pk pl gy pm pn po pp pq pr ps pt pu pv pw px py pz bj\" data-selectable-paragraph=\"\">2. A practical example<\/h1>\n<p id=\"856e\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">As a practical example, we build a classification task, which uses the wine dataset, available at this <a class=\"af nj\" href=\"https:\/\/archive.ics.uci.edu\/ml\/datasets\/Wine+Quality\" target=\"_blank\" rel=\"noopener ugc nofollow\">link<\/a>, and we track the results in Comet. The goal is to classify each wine, defined by some features, into one of the following two categories: red or white.<\/p>\n<p id=\"e500\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">The example is organized as follows:<\/p>\n<ul class=\"\">\n<li id=\"4df8\" class=\"nk nl fq be b gt nm nn no gw np nq nr ns ot nu nv nw ou ny nz oa ov oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">setup of the environment<\/li>\n<li id=\"b823\" class=\"nk nl fq be b gt oz nn no gw pa nq nr ns pb nu nv nw pc ny nz oa pd oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">loading and preparing the dataset<\/li>\n<li id=\"e537\" class=\"nk nl fq be b gt oz nn no gw pa nq nr ns pb nu nv nw pc ny nz oa pd oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">training and evaluating the model<\/li>\n<li id=\"61ca\" class=\"nk nl fq be b gt oz nn no gw pa nq nr ns pb nu nv nw pc ny nz oa pd oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">calculating the Shapley value<\/li>\n<li id=\"7cee\" class=\"nk nl fq be b gt oz nn no gw pa nq nr ns pb nu nv nw pc ny nz oa pd oc od oe ow ox oy bj\" data-selectable-paragraph=\"\">showing the results in Comet.<\/li>\n<\/ul>\n<h2 id=\"0148\" class=\"qo pf fq be pg qs qt qu pj qv qw qx pm ns qy qz ra nw rb rc rd oa re rf rg fw bj\" data-selectable-paragraph=\"\">2.1 Setup of the environment<\/h2>\n<p id=\"a194\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">Firstly, we import all the required libraries:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"104f\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">from comet_ml import Experiment\n<\/span><span id=\"6086\" class=\"qo pf fq qj b ig rh qq l iz qr\" data-selectable-paragraph=\"\">import shap\nshap.initjs()<\/span><\/pre>\n<p id=\"9374\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\"><em class=\"qf\">*Note that we need to import the <\/em><code class=\"cw qg qh qi qj b\"><em class=\"qf\">comet_ml<\/em><\/code><em class=\"qf\"> library <\/em><strong class=\"be of\"><em class=\"qf\">before <\/em><\/strong><em class=\"qf\">the shap library.<\/em><\/p>\n<p id=\"80bd\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Then, we create a file called <code class=\"cw qg qh qi qj b\">.comet.config<\/code>, which contains all the credentials used to access to Comet, and which is located in the same directory as that containing the scripting coding:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"97ec\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">[comet]\napi_key=YOUR_COMET_KEY\nworkspace=YOUR_WORKSPACE<\/span><\/pre>\n<p id=\"aa48\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Finally, we create the Comet experiment:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"2825\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">experiment = <strong class=\"qj ga\">Experiment<\/strong>(project_name='wine-classification')\nexperiment.set_name('WineClassification')<\/span><\/pre>\n<h2 id=\"1d7b\" class=\"qo pf fq be pg qs qt qu pj qv qw qx pm ns qy qz ra nw rb rc rd oa re rf rg fw bj\" data-selectable-paragraph=\"\">2.2 Loading and preparing the dataset<\/h2>\n<p id=\"79ca\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">The original dataset is divided into two files, one for red wine, and the other for white wine. So, we load the dataset as two pandas dataframes:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"c792\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">import pandas as pd\n<\/span><span id=\"6963\" class=\"qo pf fq qj b ig rh qq l iz qr\" data-selectable-paragraph=\"\">df_r = pd.read_csv('source\/wine_quality\/winequality-red.csv', sep=';')\ndf_w = pd.read_csv('source\/wine_quality\/winequality-white.csv', sep=';')\ndf_r.head()<\/span><\/pre>\n<figure class=\"ms mt mu mv mw mx mp mq paragraph-image\">\n<div class=\"my mz ec na bg nb\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nc nd c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*sGXhdmGqtnCF3ivJooo0-A.png\" alt=\"\" width=\"700\" height=\"131\"><\/figure><div class=\"mp mq ri\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*sGXhdmGqtnCF3ivJooo0-A.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*sGXhdmGqtnCF3ivJooo0-A.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*sGXhdmGqtnCF3ivJooo0-A.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*sGXhdmGqtnCF3ivJooo0-A.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*sGXhdmGqtnCF3ivJooo0-A.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*sGXhdmGqtnCF3ivJooo0-A.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*sGXhdmGqtnCF3ivJooo0-A.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*sGXhdmGqtnCF3ivJooo0-A.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"ne nf ng mp mq nh ni be b bf z dw\" data-selectable-paragraph=\"\">Image by Author<\/figcaption>\n<\/figure>\n<p id=\"8077\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">We add a new line to each dataset, indicating the related label:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"1385\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">df_r['label'] = 'red'\ndf_w['label'] = 'white'<\/span><\/pre>\n<p id=\"9548\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">We merge the two datasets:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"efa1\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">df = pd.concat([df_r, df_w])<\/span><\/pre>\n<p id=\"8686\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">We create the input and output variables:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"e174\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">X = df.drop(\"label\", axis = 1)\ny = df[\"label\"]<\/span><\/pre>\n<p id=\"486f\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">We encode the labels:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"eac4\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">from sklearn.preprocessing import LabelEncoder\n\n<\/span><span id=\"46dd\" class=\"qo pf fq qj b ig rh qq l iz qr\" data-selectable-paragraph=\"\">label_encoder = LabelEncoder()\ny = label_encoder.fit_transform(y)<\/span><\/pre>\n<p id=\"9e56\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">And we standardize input features:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"5dc0\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">from sklearn.preprocessing import StandardScaler\n<\/span><span id=\"c60d\" class=\"qo pf fq qj b ig rh qq l iz qr\" data-selectable-paragraph=\"\">scaler = StandardScaler()\nX[X.columns] = scaler.fit_transform(X[X.columns])<\/span><\/pre>\n<p id=\"f2ae\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">And finally, we split data into training and test sets:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"a973\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">from sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.10, random_state=42)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fj fk fl fm fn\">\n<div class=\"ab ca\">\n<div class=\"ch bg ev ew ex ey\">\n<blockquote class=\"rr\"><p id=\"518f\" class=\"rs rt fq be ru rv rw rx ry rz sa oe dw\" data-selectable-paragraph=\"\">Comet Artifacts lets you track and reproduce complex multi-experiment scenarios, reuse data points, and easily iterate on datasets. <a class=\"af nj\" href=\"https:\/\/www.comet.com\/site\/announcing-comet-artifacts\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Read this quick overview of Artifacts<\/a> to explore all that it can do.<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fj fk fl fm fn\">\n<div class=\"ab ca\">\n<div class=\"ch bg ev ew ex ey\">\n<h2 id=\"9f4f\" class=\"qo pf fq be pg qs qt qu pj qv qw qx pm ns qy qz ra nw rb rc rd oa re rf rg fw bj\" data-selectable-paragraph=\"\">2.3 Training and evaluating the model<\/h2>\n<p id=\"0bbf\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">We will use a Gaussian Naive Bayes classifier for our model. We train it with the training set as follows:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"09a4\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">from sklearn.naive_bayes\nimport GaussianNB<\/span><span id=\"df6d\" class=\"qo pf fq qj b ig rh qq l iz qr\" data-selectable-paragraph=\"\">model = GaussianNB()\nmodel.fit(X_train,y_train)<\/span><\/pre>\n<p id=\"9c2c\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Now we calculate the accuracy of the model:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"cce4\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">from sklearn.metrics import accuracy_score\ny_pred = model.predict(X_test)\naccuracy_score(y_test, y_pred)<\/span><\/pre>\n<p id=\"7f5e\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">The model reaches an accuracy of 0.9676923076923077.<\/p>\n<h2 id=\"feda\" class=\"qo pf fq be pg qs qt qu pj qv qw qx pm ns qy qz ra nw rb rc rd oa re rf rg fw bj\" data-selectable-paragraph=\"\">2.4 Calculating the Shapley value<\/h2>\n<p id=\"b25a\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">Firstly, we create an Explainer object as follows:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"ce4f\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">explainer = shap.Explainer(model.predict, X_train)\nshap_values = explainer(X_train)<\/span><\/pre>\n<p id=\"f5bf\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">For some models you need to specify the <code class=\"cw qg qh qi qj b\">model.predict<\/code> function as an input parameter, for other models, you should specify only the model. For the Gaussian Naive Bayes classifier, we will be using <code class=\"cw qg qh qi qj b\">model.predict<\/code>.<\/p>\n<p id=\"1ddb\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Then, I create the summary plot for the training dataset:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"8c5c\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">shap.summary_plot(shap_values, X_train)<\/span><\/pre>\n<figure class=\"ms mt mu mv mw mx mp mq paragraph-image\">\n<div class=\"my mz ec na bg nb\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nc nd c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*nHvnSr6Ed9iBMbrY60gCqA.png\" alt=\"\" width=\"700\" height=\"450\"><\/figure><div class=\"mp mq sb\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*nHvnSr6Ed9iBMbrY60gCqA.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*nHvnSr6Ed9iBMbrY60gCqA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*nHvnSr6Ed9iBMbrY60gCqA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*nHvnSr6Ed9iBMbrY60gCqA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*nHvnSr6Ed9iBMbrY60gCqA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*nHvnSr6Ed9iBMbrY60gCqA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*nHvnSr6Ed9iBMbrY60gCqA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*nHvnSr6Ed9iBMbrY60gCqA.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"ne nf ng mp mq nh ni be b bf z dw\" data-selectable-paragraph=\"\">Image by Author<\/figcaption>\n<\/figure>\n<p id=\"6e97\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">and also for the test set:<\/p>\n<pre class=\"ms mt mu mv mw qk qj ql qm ax qn bj\"><span id=\"3f41\" class=\"qo pf fq qj b ig qp qq l iz qr\" data-selectable-paragraph=\"\">explainer = shap.Explainer(model.predict, X_test)\nshap_values = explainer(X_test)\nshap.summary_plot(shap_values, X_test)<\/span><\/pre>\n<figure class=\"ms mt mu mv mw mx mp mq paragraph-image\">\n<div class=\"my mz ec na bg nb\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nc nd c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*W04NorCJQToXqkllyLQ3qw.png\" alt=\"\" width=\"700\" height=\"432\"><\/figure><div class=\"mp mq sc\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*W04NorCJQToXqkllyLQ3qw.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*W04NorCJQToXqkllyLQ3qw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*W04NorCJQToXqkllyLQ3qw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*W04NorCJQToXqkllyLQ3qw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*W04NorCJQToXqkllyLQ3qw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*W04NorCJQToXqkllyLQ3qw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*W04NorCJQToXqkllyLQ3qw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*W04NorCJQToXqkllyLQ3qw.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"ne nf ng mp mq nh ni be b bf z dw\" data-selectable-paragraph=\"\">Image by Author<\/figcaption>\n<\/figure>\n<h2 id=\"e2d1\" class=\"qo pf fq be pg qs qt qu pj qv qw qx pm ns qy qz ra nw rb rc rd oa re rf rg fw bj\" data-selectable-paragraph=\"\">2.5 Showing the results in Comet<\/h2>\n<p id=\"4748\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">After running the experiment, you will see the completed graphs in Comet, under the Graphics section, as shown in the following figure:<\/p>\n<figure class=\"ms mt mu mv mw mx mp mq paragraph-image\">\n<div class=\"my mz ec na bg nb\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nc nd c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*MMzIOaUCiQAeZH-Z7_AG4A.png\" alt=\"\" width=\"700\" height=\"391\"><\/figure><div class=\"mp mq sd\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*MMzIOaUCiQAeZH-Z7_AG4A.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"ne nf ng mp mq nh ni be b bf z dw\" data-selectable-paragraph=\"\">Image by Author<\/figcaption>\n<\/figure>\n<h1 id=\"a8c4\" class=\"pe pf fq be pg ph pi gv pj pk pl gy pm pn po pp pq pr ps pt pu pv pw px py pz bj\" data-selectable-paragraph=\"\">Summary<\/h1>\n<p id=\"166a\" class=\"pw-post-body-paragraph nk nl fq be b gt qa nn no gw qb nq nr ns qc nu nv nw qd ny nz oa qe oc od oe fj bj\" data-selectable-paragraph=\"\">Congratulations! You have just learned how to integrate Shapley values in Comet! The procedure is very simple, because once you have created the experiment, Comet will log the produced graphs automatically.<\/p>\n<p id=\"0834\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">You can download the code used in this article directly from this <a class=\"af nj\" href=\"https:\/\/github.com\/alod83\/comet_examples\/blob\/main\/SHAP%20Value.ipynb\" target=\"_blank\" rel=\"noopener ugc nofollow\">Github repository<\/a>, as well as you can see the results directly in Comet <a class=\"af nj\" href=\"https:\/\/www.comet.com\/alod83\/wine-classification\/ddd93cdfe21842a3bc8ef8f53e6ef6b1?experiment-tab=images\" target=\"_blank\" rel=\"noopener ugc nofollow\">here<\/a>!<\/p>\n<p id=\"971b\" class=\"pw-post-body-paragraph nk nl fq be b gt nm nn no gw np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe fj bj\" data-selectable-paragraph=\"\">Happy coding! Happy Comet!<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Photo by Christin Hume on Unsplash Sometimes when you build a Machine Learning model, the results produced differ from those expected, despite having appropriately taken all the necessary precautions (feature selection, model optimization, and so on). In these cases, you move on to the troubleshooting phase, where, in addition to looking for any errors in [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9,7],"tags":[],"coauthors":[132],"class_list":["post-7868","post","type-post","status-publish","format-standard","hentry","category-product","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Integrating Comet with Shap Values - Comet<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Integrating Comet with Shap Values\" \/>\n<meta property=\"og:description\" content=\"Photo by Christin Hume on Unsplash Sometimes when you build a Machine Learning model, the results produced differ from those expected, despite having appropriately taken all the necessary precautions (feature selection, model optimization, and so on). In these cases, you move on to the troubleshooting phase, where, in addition to looking for any errors in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-06T23:02:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:05:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m\" \/>\n<meta name=\"author\" content=\"Angelica Lo Duca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Angelica Lo Duca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Integrating Comet with Shap Values - Comet","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/","og_locale":"en_US","og_type":"article","og_title":"Integrating Comet with Shap Values","og_description":"Photo by Christin Hume on Unsplash Sometimes when you build a Machine Learning model, the results produced differ from those expected, despite having appropriately taken all the necessary precautions (feature selection, model optimization, and so on). In these cases, you move on to the troubleshooting phase, where, in addition to looking for any errors in [&hellip;]","og_url":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2023-10-06T23:02:10+00:00","article_modified_time":"2025-04-24T17:05:43+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m","type":"","width":"","height":""}],"author":"Angelica Lo Duca","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Angelica Lo Duca","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/"},"author":{"name":"Team Comet Digital","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/6266601170c60a7a82b3e0043fbe8ddf"},"headline":"Integrating Comet with Shap Values","datePublished":"2023-10-06T23:02:10+00:00","dateModified":"2025-04-24T17:05:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/"},"wordCount":781,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m","articleSection":["Product","Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/","url":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/","name":"Integrating Comet with Shap Values - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m","datePublished":"2023-10-06T23:02:10+00:00","dateModified":"2025-04-24T17:05:43+00:00","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*kArQi9qflVnB2-4m"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/integrating-comet-with-shap-values\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Integrating Comet with Shap Values"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/6266601170c60a7a82b3e0043fbe8ddf","name":"Team Comet Digital","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/4f0c0a8cc7c0e87c636ff6a420a6647c","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/Screen-Shot-2023-08-12-at-8.58.50-AM-96x96.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/Screen-Shot-2023-08-12-at-8.58.50-AM-96x96.png","caption":"Team Comet Digital"},"sameAs":["https:\/\/www.comet.ml\/"],"url":"https:\/\/www.comet.com\/site\/blog\/author\/teamcometdigital\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=7868"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7868\/revisions"}],"predecessor-version":[{"id":15506,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7868\/revisions\/15506"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=7868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=7868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=7868"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=7868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}