Corollary 1: coverage of weighted conformal prediction under covariate shift
ProvedConformalCovariateShift.covariate_shift_coverageAssume the covariate-shift model (6): , , are i.i.d. from , and independently, where are probability measures on and is a common conditional law. Assume is absolutely continuous with respect to , and let . For a score function and define
with the scores (4) and the weights , of (7). Then
This is the paper's main result: weighting the nonconformity scores by the likelihood ratio of test to training covariates restores the coverage guarantee of conformal prediction under covariate shift.
Formalization Note The conditional law is a Markov kernel and the joint laws are and . The likelihood ratio is any measurable, nonnegative, real-valued version of , i.e. a function equal -almost everywhere to Mathlib's rnDeriv. The score function is assumed measurable as in Theorem 1.
import Mathlib import Definitions.Def_ConformalCovariateShift_Basic open MeasureTheory ProbabilityTheory
namespace ConformalCovariateShift
theorem covariate_shift_coverage {Omega : Type*} [MeasurableSpace Omega] (P : Measure Omega)
[IsProbabilityMeasure P] {d n : ℕ}
(PX PXt : Measure (Fin d → ℝ)) [IsProbabilityMeasure PX] [IsProbabilityMeasure PXt]
(K : Kernel (Fin d → ℝ) ℝ) [IsMarkovKernel K]
(Z : Fin (n + 1) → Omega → DataPt d) (hZm : ∀ i, Measurable (Z i)) (hind : iIndepFun Z P)
(htrain : ∀ i : Fin n, Measure.map (Z i.castSucc) P = PX ⊗ₘ K)
(htest : Measure.map (Z (Fin.last n)) P = PXt ⊗ₘ K)
(hac : PXt ≪ PX) (w : (Fin d → ℝ) → ℝ) (hw_meas : Measurable w) (hw_nonneg : ∀ x, 0 ≤ w x)
(hw : ∀ᵐ x ∂PX, ENNReal.ofReal (w x) = PXt.rnDeriv PX x)
(S : ScoreFn (DataPt d)) (hS : ∀ i, Measurable (fun z : Fin (n + 1) → DataPt d => scores S z i))
(α : ℝ) (hα0 : 0 < α) (hα1 : α < 1) :
ENNReal.ofReal (1 - α) ≤
P {ω | (Z (Fin.last n) ω).2 ∈
covShiftBand S α w (fun i => Z i.castSucc ω) (Z (Fin.last n) ω).1} := by sorry
end ConformalCovariateShiftRead-back
What the Lean code literally says, in plain math · claude-opus-5-5
Let be a probability space, and let be natural numbers. Either may be ; means there are no training points. Write a data point as . The theorem fixes the following objects:
- Covariate laws. and are probability measures on .
- Response kernel. is a Markov kernel from to , so is a probability measure on for each . denotes the joint law on of a pair with and . is defined the same way.
- Data. are random variables with .
- Weight function. .
- Score function. assigns a real number to a data point and a finite multiset of data points.
- Level. is a real number.
The hypotheses are:
- each is measurable, and are mutually independent under ;
- for every , the law of is ;
- the law of is ;
- is absolutely continuous with respect to ;
- is measurable and for all ;
- (the Radon–Nikodym derivative) for -almost every ;
- for each index , the map is measurable on , where is the multiset of the other points;
- .
The conclusion is
Measurability of this event is not assumed. If it is not measurable, of it means outer measure.
The band is built from the training points (evaluated at ) and a test covariate , as follows.
Scores. For a candidate , form the points and . Their scores are
Weights. With the training covariates, set
Division by zero yields . So if the denominator is , all weights are .
Weighted distribution. On the extended real line , form the measure
Quantile. For a level ,
where the infimum is taken in the extended reals and the infimum of the empty set is .
Band. Then
Degenerate cases.
- All weights vanish. If , then is the zero measure. Since , the defining set is empty, the quantile is , and .
- No training points (). In this case if and otherwise. Either way the quantile is and .
- Quantile at in general. Whenever the quantile equals , every belongs to the band.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.