Conformalized survival analysis (right-censored outcomes)¶
Distribution-free lower prediction bounds (LPBs) for right-censored time-to-event data — with a built-in pure-NumPy Kaplan–Meier censoring estimator.
| Use it when | Outcomes are right-censored survival, churn, or time-to-failure durations (times, events) and you want calibrated lower bounds on true survival time \(T\). |
| Guarantee | Distribution-free lower prediction bound \(\mathbb{P}(T_{n+1} \ge \hat{L}(X_{n+1})) \ge 1 - \alpha\) under independent or covariate-known censoring (censoring_survival=). |
| In the library | ConformalSurvivalRegressor, kaplan_meier |
| Source | Candès, Lei and Ren (JRSS-B 2023); Gui, Hore, Ren and Barber (Biometrika 2024) |
| Example needs | pyconformal |
Distribution-free survival bound
ConformalSurvivalRegressor accounts for right-censoring via cutoff truncation (method="cutoff") or inverse probability of censoring weights (method="ipcw", using either a user-supplied censoring survival model or built-in kaplan_meier), returning lower bounds \(\hat{L}(x)\) with \(\mathbb{P}(T_{n+1} \ge \hat{L}(X_{n+1})) \ge 1 - \alpha\).
Minimal example¶
Copy, paste, run.
import numpy as np
from pyconformal import ConformalSurvivalRegressor
rng = np.random.default_rng(0)
n = 1500
X = rng.normal(size=(n, 2))
T_true = np.exp(1.5 + 0.4 * X[:, 0] + rng.normal(0.0, 0.4, size=n))
C = rng.exponential(scale=12.0, size=n)
T_obs = np.minimum(T_true, C)
events = T_true <= C
y_pred = np.exp(1.5 + 0.4 * X[:, 0])
cs = ConformalSurvivalRegressor(alpha=0.1, method="cutoff")
cs.calibrate(times=T_obs[:750], events=events[:750], y_pred=y_pred[:750])
lpb = cs.predict_lower_bound(y_pred=y_pred[750:])
print(f"censoring rate: {(~events).mean():.1%} LPB coverage: {np.mean(T_true[750:] >= lpb):.3f}")
More¶
- Full argument list: API reference
- All methods: what's inside