Partial Dependence, ICE and SHAP

What the model does as one feature moves, and why the average of many individuals can describe none of them.

Partial Dependence, ICE and SHAP

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

A partial dependence curve sweeps one feature across its range, holding the others as they are, and averages the predictions.
An ICE curve does the same for a single row, without averaging. One line per individual.
When the effect of a feature differs by subgroup, the average can be flat while no individual is.
SHAP answers a different question: how much did each feature contribute to this one prediction.

Overview

These tools answer related but different questions. Partial dependence summarises a feature’s average effect across rows; ICE shows the individual prediction curves behind that average; SHAP assigns additive contributions to one prediction relative to a baseline.

In this guide
  1. Partial dependence: the average response
  2. ICE: show each row’s curve
  3. SHAP: contributions for one prediction

Partial dependence: the average response

For a feature x, a partial-dependence plot sets x to a sequence of values for every row, keeps the other features as observed, predicts, and averages the results. It asks: how does this model’s average prediction change as x changes?

The average can hide different responses. In the visualiser, choose Interaction between x and the group as “On - effect reverses by group.” One group’s prediction rises with x while the other’s falls. Their average can look nearly flat even though neither group has a flat response.

ICE: show each row’s curve

An individual conditional expectation (ICE) curve applies the same feature sweep to one row at a time. The partial-dependence curve is the average of those predictions. Choose Show individual curves to see the variation hidden by the average; with the interaction turned on, the curves reveal why the overall line can mislead.

ICE and partial dependence describe how the fitted model responds to altered inputs. They are not causal effects. If features are strongly correlated, changing one feature while leaving all others fixed may create combinations that are rare or impossible in the real data. The model’s predictions there may not be reliable. For correlated inputs, use domain knowledge and consider methods designed to stay within the observed feature distribution, such as accumulated local effects.

SHAP: contributions for one prediction

SHAP gives each feature a contribution to a particular prediction relative to a baseline prediction. In an additive explanation, the baseline plus the feature contributions sums to the explained model output (on the method’s chosen output scale). A positive contribution moves that prediction above the baseline; a negative contribution moves it below.

SHAP values are based on Shapley-value ideas from cooperative game theory. Different explainers use different algorithms and assumptions; TreeSHAP is designed for tree models. The result depends on how missing features and feature dependence are handled, so always state the model, output scale and background data used. A contribution describes the model’s attribution under those choices—it does not show that changing the feature would cause the outcome to change.

NeedUseful view
Average model response as one feature changesPartial dependence
Variation between individual responsesICE
Feature contributions to one predictionSHAP

For broader model reliance, compare with permutation importance. For implementation details, see scikit-learn’s partial dependence guide and the SHAP documentation.

Check yourself

0 of 3

Answer without scrolling back up.

  1. A partial dependence curve is flat. What can you conclude?

  2. What does the additivity of SHAP values give you?

  3. Why can part of a partial dependence curve be untrustworthy when features are correlated?

Cheat sheet

Partial Dependence, ICE and SHAP

Plot partial dependence, ICE curves and SHAP values for one feature. See where partial dependence hides interactions the others reveal.

MACHINE LEARNING · vizlearn.in/machine_learning/partial_dependence_and_shap.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.

Teaching a course with this? Individual teachers can use it freely; for a whole department or programme, see institutional licences.