-
Notifications
You must be signed in to change notification settings - Fork 0
Conformal splitconformal normalisedinterval
Development build. This page describes
main, not a released package. The latest published Lodestar.Conformal is 0.1.0 — read its documentation.
Home › Conformal › Split conformal prediction
The prediction interval whose width varies with the input: [ŷ − q·r̂, ŷ + q·r̂].
public static (double Lower, double Upper) NormalisedInterval(double prediction, double residualEstimate, double quantile)Parameters — prediction is the model's point prediction for one new sample.
residualEstimate is the second model's r̂ at that same sample, strictly positive. quantile
is the calibrated quantile from Quantile over
NormalisedResiduals.
Returns — a (double Lower, double Upper) tuple, in the target's own units.
Exceptions — ArgumentOutOfRangeException when quantile is negative or NaN, or when
residualEstimate is zero, negative or NaN.
Example — one quantile, two points, two widths.
using Lodestar.Conformal;
double[] yTrue = [10.0, 12.0, 9.0, 15.0];
double[] yPredicted = [10.4, 11.0, 9.6, 13.5];
double[] residualEstimates = [0.5, 1.0, 0.5, 2.0];
double[] scores = SplitConformal.NormalisedResiduals(yTrue, yPredicted, residualEstimates);
double quantile = SplitConformal.Quantile(scores, alpha: 0.5);
(double Lower, double Upper) confident = SplitConformal.NormalisedInterval(11.0, 0.5, quantile);
(double Lower, double Upper) unsure = SplitConformal.NormalisedInterval(11.0, 2.0, quantile);
double tight = confident.Upper - confident.Lower; // => 1
double wide = unsure.Upper - unsure.Lower; // => 4Returns, read — the same prediction and the same quantile, four times the width, because the
second model says one point is four times as hard as the other. That is the whole difference from
Interval, which would have given both the same.
Remarks — an infinite quantile yields the whole line, as
Interval does: the multiplication carries the infinity through
rather than turning it into NaN, which is what
decision 0007 needs to
hold here too.
Pass the estimate for the point being predicted, not the calibration mean. Passing a constant
reduces this to Interval with the quantile rescaled, which is a
valid thing to do and not what the score is for.
The guarantee assumes exchangeability — see the guide's Exchangeability section.
Applies to — net10.0, netstandard2.0.
See also — SplitConformal.NormalisedResiduals,
SplitConformal.Interval.