SHAP for Binary and Multiclass Target Variables

<p>SHAP values give the contribution of a model feature to a prediction. This is also true when we use SHAP for classification. Expect, for&nbsp;<strong>binary target variables,&nbsp;</strong>we interpret these values in terms of&nbsp;<strong>log odds</strong>. For&nbsp;<strong>multiclass targets</strong>, we use&nbsp;<strong>softmax</strong>. We will:</p> <ul> <li>Discuss these interpretations in more depth</li> <li>Give the code for displaying SHAP plots for classification problems</li> <li>Explore new ways of aggregating SHAP values for multiclass targets</li> </ul> <p>You can also watch this video on the topic:</p> <p><iframe frameborder="0" height="480" scrolling="no" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2xlgOu22YgE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2xlgOu22YgE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2xlgOu22YgE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" title="SHAP for Binary and Multiclass Target Variables | Code and Explanations" width="854"></iframe></p> <h1>Previous SHAP tutorial</h1> <p>We continue on from a previous&nbsp;<a href="https://towardsdatascience.com/introduction-to-shap-with-python-d27edc23c454" rel="noopener" target="_blank">SHAP tutorial</a>. It goes into depth on SHAP plots for a continuous target variable. You will see that these plots and their insights are similar for categorical target variables. You can also find the full project on&nbsp;<a href="https://github.com/conorosully/SHAP-tutorial" rel="noopener ugc nofollow" target="_blank">GitHub</a>.</p> <h2><a href="https://towardsdatascience.com/introduction-to-shap-with-python-d27edc23c454?source=post_page-----ff2f43de0cf4--------------------------------" rel="noopener follow" target="_blank">Introduction to SHAP with Python</a></h2> <h3><a href="https://towardsdatascience.com/introduction-to-shap-with-python-d27edc23c454?source=post_page-----ff2f43de0cf4--------------------------------" rel="noopener follow" target="_blank">How to create and interpret SHAP plots: waterfall, force, mean SHAP, beeswarm and dependence</a></h3> <p><a href="https://towardsdatascience.com/introduction-to-shap-with-python-d27edc23c454?source=post_page-----ff2f43de0cf4--------------------------------" rel="noopener follow" target="_blank">towardsdatascience.com</a></p> <p>To summarise, we used SHAP to explain a model built using the&nbsp;<a href="https://archive.ics.uci.edu/ml/datasets/abalone" rel="noopener ugc nofollow" target="_blank">abalone dataset</a>. This has&nbsp;<strong>4,177</strong>&nbsp;instances and you can see examples of the features below. We use the&nbsp;<strong>8</strong>&nbsp;features to predict y &mdash; the number of&nbsp;<strong>rings&nbsp;</strong>in the abalone&rsquo;s shell. The rings are related to the age of the abalone. In this tutorial, we will bin y into different groups to create binary and multiclass target variables.</p> <p><a href="https://towardsdatascience.com/shap-for-binary-and-multiclass-target-variables-ff2f43de0cf4"><strong>Read More</strong></a></p>