regressor.PredictiveDistribution
regressor.PredictiveDistribution(point_prediction, calibration_residuals, n_cal)A conformal predictive distribution for a single test point.
This represents a step-function CDF that can be evaluated at any y value. The CDF is computed from calibration residuals and the test point prediction.
Attributes
point_prediction : float-
The base model’s point prediction for this test point.
calibration_residuals : ndarray-
Sorted residuals from calibration data.
n_cal : int-
Number of calibration points.
Methods
| Name | Description |
|---|---|
| cdf | Evaluate the CDF at y: P(Y <= y). |
| interval | Compute (1-alpha) prediction interval. |
| mean | Compute the mean of the predictive distribution. |
| pdf_approx | Approximate PDF using kernel density smoothing. |
| quantile | Compute the tau-th quantile of the predictive distribution. |
| std | Compute the standard deviation of the predictive distribution. |
cdf
regressor.PredictiveDistribution.cdf(y)Evaluate the CDF at y: P(Y <= y).
Parameters
y : float or ndarray-
Value(s) at which to evaluate the CDF.
Returns
: float or ndarray-
CDF value(s) in [0, 1].
interval
regressor.PredictiveDistribution.interval(alpha=0.1)Compute (1-alpha) prediction interval.
Parameters
alpha : float = 0.1-
Miscoverage level.
Returns
: tuple[float, float]-
(lower, upper) bounds of the interval.
mean
regressor.PredictiveDistribution.mean()Compute the mean of the predictive distribution.
Returns
: float-
Mean value (equal to point prediction for symmetric residuals).
pdf_approx
regressor.PredictiveDistribution.pdf_approx(y, bandwidth=None)Approximate PDF using kernel density smoothing.
The conformal predictive distribution is a step function, so the true PDF is a sum of delta functions. This method provides a smoothed approximation using kernel density estimation.
Parameters
y : ndarray-
Values at which to evaluate the approximate PDF.
bandwidth : float = None-
Kernel bandwidth. If None, uses Scott’s rule.
Returns
: ndarray-
Approximate PDF values.
quantile
regressor.PredictiveDistribution.quantile(tau)Compute the tau-th quantile of the predictive distribution.
Parameters
tau : float or ndarray-
Quantile level(s) in [0, 1].
Returns
: float or ndarray-
Quantile value(s).
std
regressor.PredictiveDistribution.std()Compute the standard deviation of the predictive distribution.
Returns
: float-
Standard deviation.