ConformalPredictor
A calibrated conformal predictor ready to produce intervals.
Usage
ConformalPredictor(
model,
calibration_scores,
quantile,
level,
method,
_models=None,
_fold_preds=None,
_fold_ids=None,
)Created by conformal_fit(). Wraps a fitted GAM (or, for "cv+"/"jackknife+", an ensemble of fold/leave-one-out GAMs) together with the conformity scores from calibration, so that predict() on new data returns intervals with a finite-sample marginal coverage guarantee that does not rely on the GAM’s error distribution being correctly specified — only on the calibration and test data being exchangeable.
Attributes
model: GAM-
The GAM used for point predictions: fit on the training split for
"split", or on the full data for"cv+"/"jackknife+"(in which case predictions are instead ensembled from the per-fold/per-observation models). calibration_scores: NDArray-
Absolute residuals from the calibration step (calibration split, K-fold, or leave-one-out, depending on method).
quantile: float-
The calibration quantile of
calibration_scoresused to set interval half-width ("split"only). level: float-
Nominal coverage level.
method: str-
Conformal method:
"split","cv+", or"jackknife+".
Methods
| Name | Description |
|---|---|
| predict() | Produce conformal prediction intervals on new data. |
predict()
Produce conformal prediction intervals on new data.
Usage
predict(new_data)Dispatches to the interval construction appropriate for self.method: simple values +/- quantile bands for "split", or the min/max-based "cv+" and "jackknife+" constructions that combine every fold/leave-one-out model’s prediction with every calibration residual.
Parameters
new_data: InputData- Column-oriented covariate data.
Returns
ConformalResult