Model Explainability
Intermediate 14 min read Model Explainability

Partial Dependence & ICE Plots

Slicing the model's response to a single feature

PDPs show how a feature affects predictions on average by sweeping its value and averaging the model output; ICE plots trace each individual unit. Together they reveal shape (linear? U-curve?) and heterogeneity the model learned.

partial dependencePDPICEindividual conditional expectationheterogeneitysensitivity
Before we start

What you will learn

  • Compute PDP by sweeping a feature and averaging predictions
  • Interpret PDP shape as the learned effect
  • Use ICE to see when the average hides individual behavior
Introduction

What is this?

Partial Dependence (PDP) isolates a feature's average effect: hold the rest of each sample fixed, sweep feature j over a grid, average the predictions. It plots the model's expected response as feature j varies. Individual Conditional Expectation (ICE) does the same for each sample — one line per unit — revealing how much the 'average' hides (interactions). Feature X ends up influencing an individual differently → ICE fan-outs; the PDP averages them into one band.

Motivation

Why do you need it?

  • Shows effect SHAPE, not just rank: is income linear, capped, or U-shaped?
  • Reveals interactions: PDP flat while ICE varies wildly = the feature matters, just differently per row.
  • Detects model pathologies (borderline step functions, saturation) at a glance.
  • Communicates to stakeholders: an interpretable curve beats a number list.
Think about it

Mental model

Imagine

How pizza volume responds to crust thickness

Think of

PDP vs ICE

On average thicker crust raises appreciation — but you have thick vs thin toppings (the rows). Average line smooths over the fact that some people (with toppings) love thick crust while others hate it. ICE draws one appreciation-curve PER diner; PDP is their average. Fan-outs in ICE = the toppings matter.

Mechanics

How it works

  • Pick feature j and a grid of values (percentiles of its observed range).
  • For each grid value v: copy the dataset with feature j = v, predict all rows, average → one PDP point.
  • Plot the (v, average prediction) points into a curve.
  • For ICE: keep each row separate; plot ALL rows' (v, prediction) lines.
  • Center ICE (cICE) resets each line to start at 0 for readability.

Sweep one feature; average (PDP) vs per-row (ICE).

Feature j grid
Set j = v
Predict all
Average
Per-row lines
Real world

In production

  • Pricing sanity: PDP(latency) flattening at the SLA cap validates the learned policy.
  • Risk curves: PDP(debt-to-income) monotone → supports adverse-action messaging.
  • Drift triage: a PDP that changes shape vs the previous version localizes behavior change.
Guidelines

Best practices

  • Grid spans observed percentiles (1–99%), never extrapolate off-support.
  • Always pair PDP with ICE; the average is only trustworthy if lines are coherent.
  • For monotonicity-critical features, assert PDP non-decreasing in production checks.
  • Report 2-way PDPs (contours) when a boundary is a suspected interaction.
Watch out

Common mistakes

  • Over-smoothing the curve across a genuine threshold the model learned.
  • Reading PDP causality — it's a controlled-forward slice, not an intervention.
  • Sweeping a feature whose range is unrealistic (extrapolation garbage).
  • Trusting the PDP's smooth average while ICE shows opposite slopes.
Root cause analysis

Common issues

Error
PDP climbs where practioners expect drop
Root cause

Interaction/alias with another feature (e.g. j correlated with omitted driver)

Fix

Check correlation matrix and fit a 2-way PDP (j vs its correlate) to disentangle.

Error
ICE lines virtually parallel
Root cause

Linear model or non-interacting features

Fix

Expected for additive models; only worth ICE when they diverge.

Error
PDP beyond data range shoots up
Root cause

Grid extended past observed support (extrapolated predictions)

Fix

Clamp grid to 1–99 percentiles of the real feature distribution.

When things break

Debugging tips

  • A PDP with a vertical cliff usually indicates an encoded threshold (e.g. income > 50k) — verify the feature encoding.
  • ICE fan-outs + a flat-ish PDP point to interaction, not feature uselessness.
  • Compare PDP across model versions to spot behavioral drift between releases.
  • Plot the grid density behind the curve: thick tails on sparse ranges are the riskiest band.
Interviews

Interview checkpoint

Practice

Hands-on lab

Draw PDP and ICE Curves
30 min · intermediate
In progress
Objectives
  • Compute a univariate PDP by hand
  • Plot PDE with sklearn's PartialDependenceDisplay
  • Compare PDP vs ICE on an interactive dataset

Draw PDP and ICE Curves

30 min · intermediate

0/3 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

A PDP point at feature value v is:

2

ICE echoing opposite slopes across rows is evidence of a feature interaction.

Go deeper

Official documentation