1 What Partial Dependence Means

Partial dependence is an interpretability technique for supervised predictive models. It describes how the model’s prediction changes as a given feature varies, while averaging over the remaining features. The resulting curve (or surface, for multiple features) aims to summarize the model’s “average” response to a feature, smoothing away idiosyncratic behavior of individual data points.

In contrast to methods that inspect single observations, partial dependence emphasizes a population-level view: for each candidate value of the feature of interest, predictions are computed across many plausible values of the other inputs, and then averaged.

1.1 Intuition: isolating a feature’s influence

The core intuition is to hold one feature at a chosen value and ask: “If all else were free to vary in the usual way, what would the model predict on average?” By repeating this for a grid of feature values, the method traces an interpretable association between the feature and the model output.

This “isolation” is not literal causation; it is a controlled computational experiment using the model and an assumed way to represent how other variables vary.

1.2 Mathematical formulation

Let \(f(x)\) be a trained model’s prediction for input vector \(x\), and let the feature of interest be \(x_S\) (possibly a subset of features). Let \(x_C\) denote the remaining “nuisance” variables such that the full input decomposes as \(x=(x_S,x_C)\).

A partial dependence function for the feature subset \(S\) is commonly defined as the average model prediction when \(x_S\) is fixed and \(x_C\) varies: \[ \text{PD}_S(x_S)=\mathbb{E}_{X_C}\big[f(x_S, X_C)\big]. \] In practice, the expectation is approximated numerically using a dataset or an estimate of the input distribution.

1.2.1 Averaging over nuisance variables

The averaging step is what differentiates partial dependence from a simple “slice” of the data. Rather than evaluating the model only on observed combinations \((x_S, x_C)\), partial dependence recombines them through the chosen averaging scheme.

This recombination is a major source of interpretability value, but also a major source of potential mismatch with the real joint distribution of features (especially when features are correlated).

1.2.2 Dependence on feature transformations

Because the curve is defined over the model’s input representation, partial dependence depends on the transformation used in preprocessing. For example, if the original feature is log-transformed before modeling, then the plotted axis corresponds to the transformed scale unless an explicit inverse transform is applied.

Similarly, encoding schemes for categorical variables (one-hot, ordinal, target encoding, and so on) determine what it means to “vary” a feature: the model may receive different encoded patterns rather than a single semantic category unless handled carefully.

1.3 Relationship to conditional expectations

Partial dependence is related to conditional expectation but is not identical to \(\mathbb{E}[f(X)\mid X_S=x_S]\). If features are independent in the data-generating sense (or if the averaging distribution matches the conditional structure), the distinction may shrink. When the joint distribution is not factorizable in that way, partial dependence can yield curves that reflect the model under artificial recombinations of variables.

As a result, conditional interpretations require more careful variants or assumptions.

Partial dependence belongs to a family of model-interpretation methods. Different tools address different questions: “average behavior over the population,” “pointwise behavior,” “global attribution,” or “local piecewise effects.”

2.1 Partial dependence plots (PDP)

A partial dependence plot (PDP) visualizes \(\text{PD}_S(x_S)\) as a function of \(x_S\). For one feature, it appears as a line; for two features, it is often displayed as a heatmap or surface.

The plot’s shape is influenced by the model’s functional form, by preprocessing, and by the averaging scheme used to define the expectation.

2.2 Individual conditional expectation (ICE)

Individual conditional expectation (ICE) evaluates the model prediction for each observation as the feature of interest is varied, holding other features fixed at that observation’s values. The collection of ICE curves can be summarized to indicate heterogeneity: where PDP averages may hide variation, ICE can reveal subgroups with different slopes or curvature.

2.3 Feature importance measures

Feature importance measures summarize how much a feature contributes to predictive performance, but they do not necessarily provide a “how the prediction changes with the feature” profile. Some measures are model-intrinsic (e.g., tree-based impurity reductions), while others are perturbation-based (e.g., permutation importance). Partial dependence complements these by offering an explicit functional relationship, not just a score.

2.4 Accumulated local effects (ALE) as an alternative

Accumulated local effects (ALE) is designed to address shortcomings that arise when features are correlated. Rather than averaging predictions under recombined nuisance-variable values, ALE focuses on changes in prediction across intervals of the feature and then accumulates these local differences.

This approach often yields interpretation that better aligns with the model’s behavior on the empirical support of correlated features.

2.4.1 When ALE can be preferable

ALE can be preferable when strong correlation between features makes naive partial dependence recombine unlikely combinations. If a PDP curve suggests effects in regions where there are few or no realistic observations, ALE may produce a more faithful summary by grounding the computation in local neighborhoods of the feature in the data.

2.4.2 Interpretation differences (PDP vs. ALE)

PDP answers a “global averaging under a chosen averaging distribution” question. ALE answers a “local effect under observed covariate structure” question. Both produce curves over feature values, but the underlying computation differs: PDP is prediction-level averaging, while ALE is effect-level accumulation that can mitigate extrapolation into sparse or implausible regions.

3 Computing Partial Dependence

Computing partial dependence requires repeatedly evaluating the model for multiple feature values while averaging over the remaining inputs. The main implementation choices are (i) how to choose the grid of feature values and (ii) how to approximate the expectation over nuisance variables.

3.1 Grid-based evaluation

A typical procedure uses a grid \(\{x_S^{(1)},\dots,x_S^{(m)}\}\) covering the feature’s domain. For each grid point \(x_S^{(j)}\), the method constructs modified inputs in which the feature subset is set to \(x_S^{(j)}\) while other features take values from the dataset (or another reference distribution). Model predictions for these modified inputs are averaged to yield \(\text{PD}_S(x_S^{(j)})\).

This yields a discrete approximation of the true partial dependence function and can be plotted directly.

3.2 Sampling-based approximation

In many settings, especially with continuous features or higher-dimensional subsets, the expectation \(\mathbb{E}_{X_C}[\cdot]\) is approximated via Monte Carlo sampling. The dataset itself is commonly used as a sample of the input distribution.

3.2.1 Using the dataset distribution for averaging

When the dataset is used directly, partial dependence approximates the expectation under the empirical distribution of nuisance variables. Operationally, for each grid point, the method averages predictions over all (or a subset of) rows in the dataset, substituting only the feature values of interest.

This choice ties the result to the training data distribution, so changes in data coverage can alter the curve.

3.2.2 Handling limited support and extrapolation

A practical challenge is that partial dependence may evaluate the model at combinations of inputs that lie outside the support suggested by the data. If the model is forced to produce predictions for feature values or joint configurations that rarely occur, the average can be driven by extrapolation behavior of the model.

Many implementations mitigate this only indirectly: they restrict the plotted range to regions covered by data and may use heuristic checks for whether the recombined inputs are plausible.

3.3 Choosing the feature range and resolution

The feature range determines where the PDP is drawn. The resolution controls how smooth or jagged the resulting curve appears: more grid points improve fidelity but increase computation.

For continuous features, common grid choices include quantile-based grids (to ensure equal coverage of data density) or evenly spaced grids over the observed minimum and maximum. For categorical variables, the grid typically enumerates categories or encoded levels, subject to how the encoding is defined.

3.4 Computational cost considerations

The computational burden scales with:

  • the number of grid points,
  • the number of nuisance-variable samples used for averaging, and
  • the cost of a single model evaluation.

For large datasets and fine grids, PDP can become expensive. Ensemble models and deep networks can magnify this cost. Sampling fewer nuisance rows, using fewer grid points, or caching intermediate computations are common strategies.

4 Assumptions and Practical Caveats

Partial dependence is sensitive to assumptions about how the other features should be averaged and to the presence of correlations, sparse regions, and preprocessing choices. These factors affect both the apparent shape and what the curve should be interpreted to mean.

4.1 Independence vs. correlation effects

If nuisance features are correlated with the feature of interest, the independence assumption implicit in simple recombination can distort the result. Because the method may create combinations that are unlikely under the true data distribution, the PDP may reflect counterfactual recombinations more than the model’s behavior on the real joint structure.

This does not necessarily make PDP unusable; it means the plot is best read as “model response under the averaging mechanism,” not as a guaranteed description of conditional relationships.

4.2 Extrapolation and sparse data regions

Sparse regions occur when few training examples support certain feature values. Even if the feature itself is well covered, the averaging can require nuisance-variable combinations that are rare for the given \(x_S\).

In such cases, the PDP curve can exhibit oscillations or dramatic slopes driven by model behavior outside well-supported areas. Visual diagnostics, such as marking data density or restricting ranges, can help.

4.3 Effects of preprocessing and encoding

Because partial dependence varies inputs to the trained model, preprocessing affects outcomes:

  • scaling shifts numeric axes and changes where “smoothness” appears,
  • imputation choices can create artificial plateaus,
  • encoding for categorical features can influence how categories are varied.

Interpreting the plot requires mapping the plotted axis back to the original semantic feature where appropriate.

4.4 Interaction effects and masking

When the model contains interactions, a one-feature PDP can blend multiple patterns. For instance, if the effect of feature \(x_1\) depends on \(x_2\), averaging over \(x_2\) may mask the conditional dependence, yielding a curve that seems moderate even though strong interaction effects exist.

This masking is not a failure of the method; it is an inherent consequence of marginalization. ICE plots and interaction-aware visualizations can reveal what is averaged out.

4.4.1 Visualizing interactions with 2D PDPs

Two-feature partial dependence plots extend the method to a grid over pairs \((x_{S_1}, x_{S_2})\). Heatmaps can illustrate interaction shapes, such as ridges, crossings, or nonlinear surfaces. However, the same caveats apply: recombination into implausible joint regions can still lead to misleading surfaces.

Practical implementations often restrict to ranges where both features are reasonably supported and may include overlays indicating where the data density is high.

4.5 Model dependence and calibration issues

Partial dependence reflects the learned mapping produced by the specific model, not the true data relationship. Therefore, differences between model classes, regularization strengths, and training objectives can change PDP curves.

If predicted values are poorly calibrated (e.g., predicted probabilities that do not correspond to empirical frequencies), then the PDP may look quantitatively wrong even if the qualitative trend is stable.

5 Partial Dependence in Practice

Used correctly, partial dependence supports model understanding, feature comparison, and communication with non-technical stakeholders. Used carelessly, it can overstate what the plot implies about conditional effects.

5.1 Step-by-step workflow

A typical workflow includes:

  1. Train the predictive model using a defined preprocessing pipeline.
  2. Choose the feature(s) for interpretation and decide the scale on which they will be varied.
  3. Select a grid or evaluation points for the feature values.
  4. For each grid point, replace the feature subset in the input data while keeping other features as specified by the averaging scheme.
  5. Compute predictions and average across the nuisance-variable samples.
  6. Plot the resulting PDP curve or surface, optionally alongside data density indicators.

5.2 Interpreting linear vs. non-linear shapes

A near-linear PDP suggests the model’s average response changes steadily with the feature. Curvature indicates nonlinearity, such as threshold effects, saturation, or diminishing returns. However, the curvature should be interpreted in the context of the model and averaging method: interactions can also induce apparent nonlinearity after marginalization.

When interpreting, analysts often corroborate PDP shapes with ICE, residual diagnostics, or domain knowledge.

5.3 Comparing multiple models with PDPs

Analysts may compute PDPs for several models (e.g., different algorithms, hyperparameter settings, or training subsets) to assess whether conclusions are consistent. Agreement across models can increase confidence in the robustness of observed trends.

Disagreement may indicate sensitivity to modeling assumptions, differences in learned interactions, or instability due to limited data support.

5.4 Communicating uncertainty in plots

Standard PDPs show a single mean curve. Uncertainty can be communicated by estimating variability arising from sampling, training randomness, or both.

5.4.1 Bootstrapping and variability estimates

A common approach is bootstrapping: repeatedly resample the dataset, refit the model, and recompute PDPs. The spread of curves across bootstrap replicates can be summarized as confidence bands.

The width of uncertainty bands can help users identify regions where the PDP trend is stable and regions where it is largely noise or driven by extrapolation.

6 Extensions and Variants

Partial dependence has been extended to handle multiple features, feature scaling baselines, weighting schemes, and conceptual conditioning. These variants aim to improve interpretability under practical constraints.

6.1 Multivariate (two-feature) partial dependence

For two features, partial dependence becomes a function of \((x_{S_1}, x_{S_2})\) and is computed over a 2D grid. Each grid cell corresponds to a pair of fixed feature values; predictions are averaged over nuisance variables and plotted as a surface or heatmap.

Because two-dimensional grids can become computationally heavy, resolution choices often balance detail against runtime.

6.2 Centering, scaling, and reference baselines

Raw partial dependence values can be hard to interpret when the model output has an offset or depends on the encoding. Centering or anchoring to a reference baseline is often used in practice to highlight relative change rather than absolute prediction level.

For example, some visualizations subtract the mean PDP value across the grid so that the curve shows deviations around a typical prediction level.

6.3 Weighted partial dependence

Weighted partial dependence generalizes averaging by using weights for nuisance-variable samples. Weights can reflect design considerations, target population shifts, or rebalancing to emphasize certain regions of the feature space.

Weighting changes the implied averaging distribution, so interpretation must be tied to the chosen weight scheme.

6.4 Conditional partial dependence (conceptual overview)

Conditional partial dependence aims to define an effect while respecting the conditional distribution of nuisance variables given the feature of interest. Conceptually, it replaces unconditional averaging with averaging over \(X_C\) conditioned on \(X_S=x_S\).

While exact conditional computation can be difficult, the conceptual goal is to avoid recombining features in ways that violate observed relationships. In practice, approximations and other variants (including ALE-like ideas) may be used to achieve similar interpretability improvements.

7 Evaluation, Diagnostics, and Best Practices

Interpretable partial dependence requires checks that the plotted effects correspond to model behavior in sensible regions of the feature space and that results are reproducible. Best practices focus on diagnostics, sensitivity analyses, and transparent reporting.

7.1 Checking that plotted effects match expectations

Analysts should verify that PDP trends align with reasonable expectations from model structure and data context. While the plot can reveal non-intuitive behavior, it should not contradict obvious constraints, such as monotonicity constraints or known feature validity ranges.

Cross-checks may include comparing PDP with ICE, validating against alternative interpretability approaches, or confirming that the model is not dominated by leakage or artifacts.

7.2 Sensitivity analysis for feature range choices

Because PDP curves depend on the chosen grid and range, analysts should test whether results change markedly when:

  • switching from min–max grids to quantile-based grids,
  • trimming extreme ranges,
  • adjusting resolution.

Stable trends across reasonable parameter choices support stronger claims about the model’s learned relationship.

7.3 Detecting misleading interpretations

Misleading interpretations often arise from:

  • strong feature correlation combined with naive recombination,
  • sparse or unsupported regions,
  • preprocessing mismatches between training inputs and plotted axes,
  • averaging across heterogeneous subpopulations where interactions are crucial.

Practical mitigations include adding data density indicators, using ALE or conditional variants when appropriate, and reporting that the plot describes average model response under the averaging mechanism.

7.4 Reproducibility and reporting standards

Reproducible PDP analysis requires documenting:

  • model type and training settings,
  • preprocessing and exact input representation,
  • grid selection method and feature value scaling,
  • averaging method (dataset empirical averaging, sampling size, and any weighting),
  • uncertainty estimation strategy (if any).

Including these details helps others interpret what the plot means and replicate results under the same assumptions.