Documentation

CslibFrontier.MachineLearning.OnlineLearning.Calibration

Calibrated forecasting and the Foster–Vohra theorem #

Formalizes binary online calibration via Blackwell approachability [Blackwell1956, FosterVohra1998]:

  1. Deterministic impossibility (deterministic_calError_ge_half): every deterministic forecaster f : List Bool → ℝ incurs exact ℓ₁ calibration error at least 1 / 2 against an adaptive binary adversary (y_t = decide (f h < 1 / 2)) for every horizon T ≥ 1. Hence randomization is strictly required for asymptotic calibration.
  2. Calibration payoff and ℓ₁ ball (calPayoff, l1Ball): on the uniform grid gridPoint K i = i / K ∈ [0, 1] (i : Fin (K + 1)), round-t prediction i against outcome b : Bool incurs the vector payoff (outcome b - i / K) • e_i ∈ EuclideanSpace ℝ (Fin (K + 1)). Its cumulative vector average has ℓ₁ norm equal to the classic empirical ℓ₁ calibration error (1 / T) * ∑ k, |∑_{i_t = k} (outcome b_t - gridPoint K k)|.
  3. Response condition & explicit two-point Foster–Vohra strategy (calPayoff_response, fosterVohraRule, fosterVohraRule_halfspace): verifies both Blackwell's response condition (SatisfiesResponseCondition) for the ℓ₁ ball l1Ball K (1 / (2 * K)) (by rounding to the nearest grid point) and an explicit closed-form 2-point-supported distribution fosterVohraDist K w satisfying the supporting halfspace condition directly (handling endpoints w 0 ≤ 0, 0 ≤ w K and adjacent sign change w i ≥ 0 ≥ w (i + 1) with exact weight balance canceling outcome b).
  4. Finite-sample and ε–δ calibration bounds (fosterVohra_expected_calError_le, fosterVohra_prob_calError_ge_le, exists_calibrated_forecaster): against every adaptive binary adversary adv : List (Fin (K + 1)) → Bool,
    • 𝔼[calError_T] ≤ 1 / (2 * K) + 2 * √((K + 1) / T) (giving O(T ^ (-1 / 3)) when K ≈ T ^ (1 / 3)), and
    • Pr[calError_T ≥ ε] ≤ 4 * (K + 1) / (T * (ε - 1 / (2 * K)) ^ 2) whenever 1 / (2 * K) < ε.

Main definitions #

Main results #

References #

Binary outcome in {0, 1} ⊆ ℝ.

Adversarial prefix history (most-recent-first) generated against a deterministic forecaster f : List Bool → ℝ by playing the opposite extreme bit decide (f h < 1 / 2).

Exact bucketed ℓ₁ calibration error (1 / T) * ∑ q, |∑_{p t = q} (outcome (y t) - q)| over all distinct real forecasts q issued during the first T rounds.

theorem Cslib.MachineLearning.OnlineLearning.Blackwell.deterministic_calError_ge_half (f : List Bool → ℝ) {T : ℕ} (hT : 0 < T) :
have y := fun (t : ℕ) => decide (f (detAdversaryHistory f t) < 1 / 2); have p := fun (t : ℕ) => f (detAdversaryHistory f t); 1 / 2 ≤ detCalError p y T

Deterministic forecasters cannot be calibrated [FV98]: for every deterministic forecaster f : List Bool → ℝ and every horizon T ≥ 1, the adaptive adversary playing y t = true iff f h_t < 1 / 2 forces exact bucketed ℓ₁ calibration error at least 1 / 2.

Uniform grid point i / K ∈ [0, 1] indexed by i : Fin (K + 1).

noncomputable def Cslib.MachineLearning.OnlineLearning.Blackwell.calPayoff (K : ℕ) (i : Fin (K + 1)) (b : Bool) :

Vector-valued calibration payoff for grid size K: forecasting i : Fin (K + 1) when binary outcome b : Bool occurs produces (outcome b - gridPoint K i) • e_i.

Closed ℓ₁ ball {x : EuclideanSpace ℝ (Fin n) | ∑ k, |x k| ≤ r}.

Triangle bound relating ∑ |x k| to Euclidean distance distToSet (l1Ball n r) x.

Blackwell's response condition holds for binary calibration (calPayoff K targeting l1Ball (K + 1) (1 / (2 * K))): against any mixed outcome q ∈ Δ(Bool), placing mass 1 on the grid point nearest to q true keeps the expected vector payoff inside the ℓ₁ ball of radius 1 / (2 * K).

Explicit 2-point-supported distribution on Fin (K + 1) forcing the l1Ball supporting halfspace of w : EuclideanSpace ℝ (Fin (K + 1)) against both binary outcomes true, false [FV98].

theorem Cslib.MachineLearning.OnlineLearning.Blackwell.fosterVohraDist_inner_le {K : ℕ} (hK : 0 < K) (w : EuclideanSpace ℝ (Fin (K + 1))) (b : Bool) :
∃ s ∈ l1Ball (K + 1) (1 / (2 * ↑K)), inner ℝ w (expectedPayoff (calPayoff K) (fosterVohraDist K w) b) ≤ inner ℝ w s

Core Foster–Vohra halfspace lemma: for every dual vector w, fosterVohraDist K w forces ⟪w, expectedPayoff (calPayoff K) (fosterVohraDist K w) b⟫ ≤ ⟪w, s*⟫ for an explicit s* ∈ l1Ball (K + 1) (1 / (2 * K)) against both binary outcomes b : Bool.

Explicit stationary Foster–Vohra feedback rule targeting l1Ball (K + 1) (1 / (2 * K)): given current realized average error vector y, returns fosterVohraDist K (y - Π_S y).

theorem Cslib.MachineLearning.OnlineLearning.Blackwell.fosterVohraRule_halfspace {K : ℕ} (hK : 0 < K) (y : EuclideanSpace ℝ (Fin (K + 1))) (b : Bool) :
have S := l1Ball (K + 1) (1 / (2 * ↑K)); have s := metricProjection S y; inner ℝ (y - s) (expectedPayoff (calPayoff K) ((fosterVohraRule K).prob y) b - s) ≤ 0

fosterVohraRule K satisfies Blackwell's supporting-halfspace inequality for every y and every binary outcome b : Bool.

noncomputable def Cslib.MachineLearning.OnlineLearning.Blackwell.empiricalCalError (K : ℕ) (adv : List (Fin (K + 1)) → Bool) (h : List (Fin (K + 1))) :

Realized ℓ₁ empirical calibration error along a reverse-ordered history h : List (Fin (K + 1)) against an adaptive binary adversary adv : List (Fin (K + 1)) → Bool: (1 / |h|) * ∑ k, |∑_{i_t = k} (outcome (y_t) - k / K)|.

theorem Cslib.MachineLearning.OnlineLearning.Blackwell.fosterVohra_expected_calError_le {K : ℕ} (hK : 0 < K) (adv : List (Fin (K + 1)) → Bool) {T : ℕ} (hT : 0 < T) :
expectHistory ((fosterVohraRule K).toStrategy (calPayoff K) adv) T [] (empiricalCalError K adv) ≤ 1 / (2 * ↑K) + 2 * √(↑(K + 1) / ↑T)

Foster–Vohra finite-sample expected ℓ₁ calibration bound [FV98]: for every grid size K ≥ 1, horizon T ≥ 1, and arbitrary adaptive binary adversary adv : List (Fin (K + 1)) → Bool, the explicit two-point-supported fosterVohraRule K achieves 𝔼[empiricalCalError K adv h] ≤ 1 / (2 * K) + 2 * √((K + 1) / T).

theorem Cslib.MachineLearning.OnlineLearning.Blackwell.fosterVohra_prob_calError_ge_le {K : ℕ} (hK : 0 < K) (adv : List (Fin (K + 1)) → Bool) {T : ℕ} (hT : 0 < T) {ε : ℝ} (hε : 1 / (2 * ↑K) < ε) :
(expectHistory ((fosterVohraRule K).toStrategy (calPayoff K) adv) T [] fun (h : List (Fin (K + 1))) => if ε ≤ empiricalCalError K adv h then 1 else 0) ≤ 4 * ↑(K + 1) / (↑T * (ε - 1 / (2 * ↑K)) ^ 2)

Foster–Vohra high-probability calibration tail bound [FV98]: whenever ε exceeds the grid discretization 1 / (2 * K), for every adaptive binary adversary adv and horizon T ≥ 1, Pr[empiricalCalError K adv h ≥ ε] ≤ 4 * (K + 1) / (T * (ε - 1 / (2 * K)) ^ 2).

theorem Cslib.MachineLearning.OnlineLearning.Blackwell.exists_calibrated_forecaster {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) :
∃ (K : ℕ) (T₀ : ℕ), 0 < K ∧ 0 < T₀ ∧ ∀ (T : ℕ), T₀ ≤ T → ∀ (adv : List (Fin (K + 1)) → Bool), expectHistory ((fosterVohraRule K).toStrategy (calPayoff K) adv) T [] (empiricalCalError K adv) ≤ ε ∧ (expectHistory ((fosterVohraRule K).toStrategy (calPayoff K) adv) T [] fun (h : List (Fin (K + 1))) => if ε ≤ empiricalCalError K adv h then 1 else 0) ≤ δ

Existence of (ε, δ)-calibrated randomized forecasters [FV98]: for every ε > 0 and δ > 0, there exist an explicit grid resolution K ≥ 1 and horizon T₀ ≥ 1 (K = ⌈2 / ε⌉₊, T₀ = O(K / (δ * ε ^ 2))) such that fosterVohraRule K achieves both 𝔼[empiricalCalError K adv h] ≤ ε and Pr[empiricalCalError K adv h ≥ ε] ≤ δ for all T ≥ T₀ and every adaptive binary adversary adv.