SHAP Plots: A Deep Dive into Explainable AI
Explore how a model's prediction differs from a baseline and compare the meaning of a local contribution with a summary across observations.
Quick Answer
SHAP (SHapley Additive exPlanations) plots are powerful visualization tools that help interpret machine learning models by showing how each feature contributes to predictions, while accounting for complex feature interactions and dependencies.

Reconstruct one prediction
Suppose a regression model has a baseline predicted journey time of thirty minutes. For one journey, an explanation assigns eight extra minutes to distance, minus three minutes to departure time and one extra minute to another feature. In an additive explanation on this output scale, the contributions sum to six minutes. Adding them to the baseline gives a prediction of thirty-six minutes. This accounts for the model's output on that record. It does not establish how changing one real-world condition would affect the journey.
Relationships Between Quantitative Datasets
Identifying Explanatory and Response Variables
- A person’s height and weight
- A professional basketball player’s salary and their average points scored per game (which is a measure of how good they are at basketball)
- The length and width of leaves on a tree
- As people get taller, their weight tends to increase. But if a person goes on a diet and loses weight, we don’t expect them to also get shorter. So, weight depends on height. That means we’ll say that the response variable is weight and the explanatory variable is height.
- The more points a basketball player scores, the more money they should make. But if a basketball player gets a raise, we wouldn’t expect them to get better at basketball as a result. So, the response is salary and the explanatory is points per game.
- The way that the length and width of leaves are connected isn’t clear. It seems reasonable that as the width goes up, so would the length. But the other direction is also plausible: as the length goes up, so does the width. Without a clear dependence relationship, we’re free to declare either to be the response and the other to be the explanatory.
Creating Scatter Plots
Creating Scatter Plots Without Technology
| Name | Midterm grade | Final grade |
| Student 1 | 88 | 84 |
| Student 2 | 71 | 80 |
| Student 3 | 75 | 77 |
| Student 4 | 94 | 95 |
| Student 5 | 68 | 73 |
| Name | (Midterm, Final) |
| Student 1 | (88, 84) |
| Student 2 | (71, 80) |
| Student 3 | (75, 77) |
| Student 4 | (94, 95) |
| Student 5 | (68, 73) |
Creating Scatter Plots in Google Sheets
Reading and Interpreting Scatter Plots
Positive and Negative Linear Relationships
Interpreting Scatter Plots
- Is there a curved pattern in the data? If yes, stop here. If no, continue to part b.
- Classify the strength and direction of the relationship. Make a guess at the value of .
- Yes, there is a curved pattern.
- No, there’s no curved pattern.
- Since the points tend upward as we move from left to right, this is a positive relationship. The points seem pretty closely grouped around a line, so it’s fairly strong. Comparing this scatter plot to those in diagram to diagram, we can see that the relationship is stronger than the one in diagram ( ) but not as strong as the one in diagram (). So, the value of the correlation coefficient is somewhere between the two. We might guess that .
- No, there’s no curved pattern.
- Since the points tend downward as we move from left to right, this is a negative relationship. The points are not tightly grouped around a line, but the pattern is clear. It looks like it has approximately the same strength as the plot in diagram, just with the opposite sign. So, we might guess that .
- No, there’s no curved pattern.
- Since the points don’t really tend upward or downward as we move from left to right, there is no real relationship here. Thus, .
Finding the Correlation Coefficient
Linear Regression
Finding the Equation of the Regression Line
Finding the Equation of the Regression Line from Statistics
Finding the Equation of the Regression Line Using Google Sheets
Using the Equation of the Regression Line
| Name | Midterm Grade | Final Grade |
| Allison | 88 | 84 |
| Benjamin | 71 | 80 |
| Carly | 75 | 77 |
| Daniel | 94 | 95 |
| Elmo | 68 | 73 |
Applying the Equation of the Regression Line
- What is the equation of the regression line for runs (R) vs. hits (H)?
- How many runs would we expect a team to score if the team got 1500 hits in a season?
- Did the Kansas City Royals (KCR) overperform or underperform in terms of runs scored, based on their hit total? By how much?
- Write a sentence to interpret the slope of the regression line.
- Using Google Sheets, we find that the regression line equation is , where is the number of runs scored and is the number of hits.
- Plugging 1500 into the equation of the regression line, we get . We would predict that a team with 1500 hits would score 870 runs.
- The Royals had 1356 hits, so we would predict their run total to be . They actually scored 691 runs, so they underperformed expectations by 52 runs .
- The slope gives us the predicted change in the response that corresponds to a one unit increase in the explanatory variable. So, we expect one additional hit to result in 0.884 more runs. Since 0.884 runs doesn’t really make sense, we can get a better interpretation by multiplying through by ten or one hundred: Ten additional hits will result in almost nine additional runs, or a hundred additional hits will yield on average just over 88 additional runs.
