Conformal 0.1.0 prediction - CyrilB1531/lodestar GitHub Wiki

Lodestar.Conformal 0.1.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

Split conformal prediction โ€” Lodestar.Conformal

A model gives you one number, or one class. This page turns it into an interval, or a set, that contains the truth a stated fraction of the time โ€” 90 % of the time, say โ€” and the fraction is a finite-sample guarantee rather than an asymptotic hope. It costs a held-out calibration set and nothing else: no retraining, no distributional assumption, and no assumption that the model is any good. A bad model gets wide intervals, which is the correct answer.

There is one type, SplitConformal, and it is static. The calibrated quantile is handed back to you rather than kept inside an object, because it is the number that carries the guarantee and you should be able to look at it.

The whole procedure is three calls:

  1. Score the calibration set โ€” AbsoluteResiduals for a regressor, LeastAmbiguousScores for a classifier.
  2. Turn the scores into one number โ€” Quantile.
  3. Apply it to a new prediction โ€” Interval or PredictionSet.

The guarantee assumes exchangeability. It does not hold for time series, for data with drift, or for any split that leaks. The intervals still come out; they simply do not cover, and nothing in the output says so. The guide's Exchangeability section is the part of this documentation worth reading before the API.

Member What it does
SplitConformal.Quantile The calibrated quantile: the k-th smallest score, with k = ceil((n + 1)(1 โˆ’ ฮฑ)).
SplitConformal.AbsoluteResiduals A regressor's calibration scores, |y โˆ’ ลท|.
SplitConformal.Interval [ลท โˆ’ q, ลท + q] around a point prediction.
SplitConformal.LeastAmbiguousScores A classifier's LAC calibration scores, 1 โˆ’ pฬ‚(true class).
SplitConformal.PredictionSet Every class whose probability clears 1 โˆ’ q. Possibly none.