Fast Estimation of Partial Dependence Functions using Trees

Jinyang Liu, Tessa Steensgaard, Marvin N. Wright, Niklas Pfister, Munir Hiabu

As machine learning models grow more complex, "black-box" interpretability becomes a mission-critical requirement. Most practitioners rely on Partial Dependence (PD) functions, which show how a specific feature affects a model's prediction on average. These functions are the mathematical bedrock behind popular explainability tools like SHAP (Shapley Additive Explanations) and PD plots.

However, there is a major trade-off in the current ecosystem between consistency and computational speed. FastPD is a new tree-based algorithm designed to bridge this gap, efficiently and consistently estimating PD functions without falling prey to the biases of existing fast methods.

The Problem: Consistency vs. Speed

When extracting explanations from tree-based models (like XGBoost or LightGBM), practitioners typically face a dilemma:

  1. The Inconsistency of Path-Dependency: The most popular fast algorithm, TreeSHAP-path, uses the internal routing structure of the decision tree as a proxy for the data distribution. While incredibly fast, it is mathematically inconsistent. If features are correlated—which is almost always true in real-world data—it produces biased explanations. The authors provide a striking proof that TreeSHAP-path can yield entirely different explanations for two trees that produce identical predictions, simply because their internal split structures differ.
  2. The Computational Wall: "Interventional" methods, which are mathematically consistent and unbiased, typically scale quadratically—$O(n^2)$—with the number of samples. For large datasets, computing high-quality explanations becomes prohibitively slow, forcing users to subsample heavily and lose precision.

The Solution: FastPD Methodology

The core innovation of FastPD is exploiting the decision tree's mathematical structure to separate the estimation process into two distinct phases:

  1. Augmentation (Precomputation): The algorithm traverses the tree once. For every leaf, it identifies which features were used in the path to get there. It then pre-calculates "coverage" lists, essentially tracking which background samples would have reached that leaf if certain feature splits were ignored.
  2. Evaluation: Once the tree is augmented, retrieving the PD function for any feature subset becomes a simple lookup and summation task.

By treating the decision tree as a weighted sum of indicator functions, FastPD shifts the computational complexity from $O(n_e \cdot n_b)$ (evaluation points $\times$ background samples) to a much more manageable $O(n_e + n_b)$ for moderately deep trees.

Key Results

The authors validated FastPD using a mix of synthetic Data Generating Processes (DGPs) and 35 real-world datasets from OpenML. The results highlight massive improvements in both speed and accuracy.

Massive Speedups

FastPD is the first algorithm to provide interventional (consistent) PD estimates that scale linearly with the number of observations. This allows researchers to use the entire training set as a background distribution rather than subsampling to a few hundred points.

Log-log plot demonstrating the linear time complexity of FastPD compared to the quadratic scaling of traditional interventional methods.

In runtime comparisons, FastPD proved to be orders of magnitude faster than VanillaPD and TreeSHAP-int. For a dataset of 8,000 samples, FastPD took roughly 1 second, whereas the standard model-agnostic approach took nearly 4 hours.

Error Reduction and Consistency

Because FastPD can estimate PD functions for any subset of features, it extracts a full functional ANOVA decomposition. This cleanly separates main effects from interaction effects, preventing the "smearing" often seen in standard SHAP values.

Box plots showing Mean Squared Error (MSE) across different methods. FastPD's error approaches zero as sample size increases, while TreeSHAP-path hits an error floor.

As the number of background samples increases, the Mean Squared Error (MSE) of FastPD consistently drops toward zero. In contrast, TreeSHAP-path hits an "error floor." Because its fundamental logic is biased when features are correlated, adding more data does not fix the underlying mathematical inconsistency.

Limitations and Future Work

While FastPD sets a new standard for tree explainability, it has limitations:

  • The Depth Trap: The algorithm's memory usage grows exponentially with the number of unique features split in a single tree path ($2^F$). While perfect for Gradient Boosted Trees (which typically use shallow depths of 3–6), it may struggle with very deep, unpruned Random Forest trees.
  • Extrapolation Risks: Like all PD-based methods, FastPD can suffer from "extrapolation bias" by evaluating the model in regions of the feature space where no real data exists. Future work may combine FastPD with Accumulated Local Effects (ALE) to mitigate this.
  • Surrogate Models: For non-tree models like Neural Networks, FastPD requires training a surrogate tree first, introducing an additional layer of approximation error.

Summary updated

BibTeX
@inproceedings{liu2025fast,
  author = {Jinyang Liu and Tessa Steensgaard and Marvin N. Wright and Niklas Pfister and Munir Hiabu},
  title = {{Fast Estimation of Partial Dependence Functions using Trees}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=JTOOU5SsXT},
}
Figure