Part XXI — Explainable AI & Model Interpretability · Chapter 10

Partial dependence & ICE plots

Hook

Integrated gradients explains one prediction at a time. What if you want the bigger picture — how does the model's answer change, on average, as one feature sweeps across its whole range? Averaging sounds safe. It isn't always.

Intuition
PDP (dashed, flat at 0) vs this row's ICE curve (slope 2)

Sweep x1x_1 across a grid, holding x2x_2 at one row's actual value. Different rows trace completely different lines — some rising, some falling — while the average across all of them stays perfectly flat.

Formalize

A partial dependence plot (PDP) sweeps one feature x1x_1 across a grid, holding every other feature at each training row's own observed value, and averages the resulting prediction across all rows:

PDP^(x1)=1ni=1nf(x1,x2(i))\widehat{\text{PDP}}(x_1) = \frac{1}{n}\sum_{i=1}^{n} f\big(x_1, x_2^{(i)}\big)
  • PDP^(x1)\widehat{\text{PDP}}(x_1) — the estimated partial dependence at x1x_1: the model's average prediction when this feature is fixed there.
  • x1x_1 — the feature being swept across a grid of values.
  • x2(i)x_2^{(i)} — every other feature, held at row ii's own observed value instead of being swept.
  • nn — the number of training rows being averaged over.
  • ff — the trained model's prediction function.
  1. ICE curves: the same sweep, per row

    An ICE (individual conditional expectation) curve is the same sweep, but for one row at a time, with no averaging.

  2. PDP is the mean of the ICE curves

    PDP is the average of all the ICE curves — which means whatever the ICE curves disagree about, the PDP quietly erases.

Play
four individual curves, four different slopes — the average (dashed) stays flat at zero the entire time

Four rows, four different slopes — some rising steeply, some falling steeply, driven entirely by each row's own x2x_2. The dashed average line never leaves zero, the entire time.

Worked example

f(x1,x2)=x1x2f(x_1, x_2) = x_1 \cdot x_2 — a pure interaction, no effect of x1x_1 on its own. Four rows: x2{2,1,1,2}x_2 \in \{2, 1, -1, -2\}:

  1. Every row has a real, strong effect from x1

    At x1=2x_1=2, each row's prediction is x1×x2(i)x_1\times x_2^{(i)}:

    • x2=2x_2=2: 2×2=42\times2=4
    • x2=1x_2=1: 2×1=22\times1=2
    • x2=1x_2=-1: 2×(1)=22\times(-1)=-2
    • x2=2x_2=-2: 2×(2)=42\times(-2)=-4

    A spread of 88x1x_1 clearly matters, a lot, for every single row.

  2. The average cancels it exactly

    (4+224)/4=0(4 + 2 - 2 - 4)/4 = 0. This holds at every grid value of x1x_1 from 2-2 to 22: the PDP is 0,0,0,0,00, 0, 0, 0, 0 — flat, because the symmetric x2x_2 values always cancel regardless of x1x_1.

  3. A flat PDP doesn't mean a feature doesn't matter

    The PDP alone would say "x1x_1 has no effect." The ICE curves say the opposite: x1x_1's effect is real and large, it just flips sign depending on x2x_2 — an interaction the averaged view is structurally incapable of showing.

Checkpoint

Find the value of x1, among the five grid points, where the rows disagree the most — even though the PDP is flat everywhere.

Pick an x1 value to try it
Summary
PDP(x1)=1niICEi(x1)— an average can erase exactly what you’re looking for\text{PDP}(x_1) = \frac{1}{n}\sum_i \text{ICE}_i(x_1) \qquad\text{— an average can erase exactly what you're looking for}

A PDP is only trustworthy when the ICE curves it's averaging roughly agree with each other. When they don't — because of an interaction, like here, or any other source of heterogeneity — the PDP isn't wrong, exactly, but it's answering a question ("what's the effect on average?") that isn't the one usually being asked ("does this feature matter?"). The next chapter turns to a model family where feature importance comes from the training procedure itself, not from probing an already-trained model after the fact.