Abstract
We define extrapolation as any type of statistical inference on a conditional function (e.g., a conditional expectation or conditional quantile) evaluated outside of the support of the conditioning variable. This type of extrapolation occurs in many data analysis applications and can invalidate the resulting conclusions if not taken into account. While extrapolating is straightforward in parametric models, it becomes challenging in nonparametric models. In this work, we extend the nonparametric statistical model to explicitly allow for extrapolation and introduce a class of extrapolation assumptions that can be combined with existing inference techniques to draw extrapolation-aware conclusions. The proposed class of extrapolation assumptions stipulate that the conditional function attains its minimal and maximal directional derivative, in each direction, within the observed support. We illustrate how the framework applies to several statistical applications including prediction and uncertainty quantification. We furthermore propose a consistent estimation procedure that can be used to adjust existing nonparametric estimates to account for extrapolation by providing lower and upper extrapolation bounds. The procedure is empirically evaluated on both simulated and real-world data.
Introduction: The Nonparametric Extrapolation Gap
Modern nonparametric models, such as Random Forests and Neural Networks, excel at interpolation—making predictions within the range of observed data. However, they are notoriously unreliable when tasked with extrapolation. Unlike parametric models that impose a global structure (e.g., a linear trend), nonparametric models lack a principled mechanism to determine behavior outside the observed support. Consequently, they often produce arbitrary or overconfident predictions in out-of-distribution scenarios.
Existing approaches to this problem often rely on restrictive assumptions, such as global linearity or periodicity. In this work, we propose a middle ground: a framework that allows for nonparametric flexibility while providing "safety rails" through derivative-based bounds.
A Derivative-Based Framework
The core of our approach leverages Taylor’s Theorem to bound a function $f(x)$ at an unseen point $x$ using an "anchor point" $x_0$ from the observed support $\mathcal{D}$. The value at $x$ is expressed as a polynomial based on derivatives at $x_0$, plus a remainder term.
The fundamental assumption introduced is the $q$-th derivative dominated assumption. We assume that the $q$-th directional derivatives of the true function outside the observed data are bounded by the minimum and maximum $q$-th derivatives observed within the support. Essentially, we assume that the function's rate of change outside the data does not exceed the extremes already witnessed.
As shown in Figure 1, these bounds naturally widen as the distance from the observed support increases. The choice of $q$ determines the "smoothness" of the extrapolation: $q=1$ assumes bounded first derivatives (slopes), while $q=2$ assumes bounded second derivatives (curvature).
The Xtrapolation Procedure
To implement this framework, we developed the Xtrapolation algorithm:
- Derivative Estimation: We utilize a combination of Random Forests and local polynomials (
rfpoly-v) to estimate directional derivatives at every data point. - Optimization: We calculate the Taylor expansion for every possible anchor point in the dataset, selecting those that provide the tightest valid upper and lower bounds.
- Uncertainty Quantification: The gap between these bounds serves as a natural measure of extrapolation uncertainty.
Key Insights and Empirical Results
Our framework offers several advantages over standard nonparametric methods:
- Seamless Transition: Within the observed support, the bounds collapse to the standard nonparametric estimate. Extrapolation-awareness is only activated when moving outside the data range.
- Function-Aware Uncertainty: Unlike simple distance-based metrics, our extrapolation score accounts for the function's local behavior. A flat function allows for further extrapolation with less uncertainty than a volatile one.
- Reliable Coverage: In evaluations on real-world datasets (e.g., Biomass and Abalone), standard methods like Quantile Regression Forests (QRF) failed to maintain coverage when extrapolating. In contrast, the Xtrapolation procedure maintained valid coverage by appropriately widening intervals.
Conclusion
By formalizing extrapolation through derivative-dominated assumptions, we provide a principled way to handle out-of-distribution inference in nonparametric settings. While the current implementation faces some computational challenges with very large datasets, it offers a robust path forward for making machine learning models more "honest" about what they do not know. Future work will explore additional shape constraints, such as convexity, to further refine these bounds in specific scientific contexts.
Summary updated