Conformal 0.1.0 splitconformal absoluteresiduals - CyrilB1531/lodestar GitHub Wiki
Lodestar.Conformal 0.1.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
A regressor's calibration scores: how far each prediction missed, without a sign.
public static double[] AbsoluteResiduals(ReadOnlySpan<double> yTrue, ReadOnlySpan<double> yPredicted)Parameters โ yTrue are the observed values and yPredicted the model's predictions for the
same points, in the same order and of the same length.
Returns โ a fresh double[], one |y โ ลท| per point, in the input's order. Hand it to
Quantile.
Exceptions โ ArgumentException when the two spans have different lengths.
Example โ three calibration points: one missed by 1, one by 0.5, one exactly right.
using Lodestar.Conformal;
double[] yTrue = [1.0, 2.0, 3.0];
double[] yPredicted = [2.0, 1.5, 3.0];
double[] residuals = SplitConformal.AbsoluteResiduals(yTrue, yPredicted);
double first = residuals[0]; // => 1
double second = residuals[1]; // => 0.5
double third = residuals[2]; // => 0Remarks โ this is MAPIE's AbsoluteConformityScore, what SplitConformalRegressor uses unless
told otherwise. Nothing here is fitted: the calibration set must be data the model did not
train on, and this method has no way to check that for you.
The absolute value is what makes the resulting interval symmetric, and that is a real limitation rather than a simplification. Every prediction gets the same width, so a model whose error grows with the target โ most of them โ gets intervals too wide where it is confident and too narrow where it is not, while still covering at the rate asked for overall. A normalised score fixes that by dividing the residual by a second model's estimate of the local spread; this package does not ship one yet, and reaching for a signed residual instead does not help โ it produces a one-sided interval, not an adaptive one.
Applies to โ net10.0, netstandard2.0.
See also โ SplitConformal.Quantile,
SplitConformal.Interval, the
Python equivalence table.