Skip to content

Localized conformal regression (RLCP & LCP)

Kernel-localized prediction intervals that adapt to feature-space heteroscedasticity without fitting a separate quantile or variance model.

Use it when Residual spread varies across the input space X and you want locally adaptive intervals directly from a point model.
Guarantee mode="rlcp" (default): exact finite-sample marginal coverage \(\ge 1 - \alpha\) under exchangeability and asymptotic conditional validity.
In the library LocalizedConformalRegressor (mode="rlcp" or "lcp", kernel="gaussian"|"laplace"|"epanechnikov")
Source Hore and Barber (JRSS-B 2025); Guan (Biometrika 2023)
Example needs pyconformal

Finite-sample guarantee

With mode="rlcp" (Randomly-Localized Conformal Prediction, Hore & Barber 2025), perturbing each test input to an anchor \(\tilde{X} \sim K(X_{\text{test}}, \cdot)\) and taking the weighted conformal quantile with weights \(K(X_i, \tilde{X})\) and test weight \(K(X_{\text{test}}, \tilde{X})\) guarantees exact finite-sample marginal coverage \(\mathbb{P}(Y_{n+1} \in \hat{C}(X_{n+1})) \ge 1 - \alpha\).

Minimal example

Copy, paste, run.

import numpy as np
from pyconformal import LocalizedConformalRegressor
from pyconformal.point_models import ExtraTrees

rng = np.random.default_rng(0)
X = rng.uniform(0.0, 10.0, size=(1500, 1))
y = np.sin(X[:, 0]) + rng.normal(0.0, 0.2 + 0.4 * X[:, 0])

model = ExtraTrees(n_estimators=50, max_depth=7, random_state=0).fit(X[:500], y[:500])
lcp = LocalizedConformalRegressor(model, alpha=0.1, bandwidth=0.35, mode="rlcp", random_state=0)
lcp.calibrate(X[500:1000], y[500:1000])
iv = lcp.predict_interval(X[1000:])

cov = np.mean((y[1000:] >= iv[:, 0]) & (y[1000:] <= iv[:, 1]))
w = iv[:, 1] - iv[:, 0]
print(f"coverage: {cov:.3f}  width(x<3): {w[X[1000:, 0] < 3].mean():.2f}  width(x>7): {w[X[1000:, 0] > 7].mean():.2f}")

More