ML.Surrogate

Surrogate-loss learning: generic convex empirical risk minimization with proper binary losses — losses whose conditional risk is minimized at the true probability — and their Fisher consistency (the population-risk minimizer recovers E[Y∣X]).

Clamped­Square 4 core · 2 supporting The clamped square is a globally Lipschitz surrogate for the squared map on a bounded prediction range. ★ clampedSq★ clampedSq_eq_sq★ clampedSq_le_sq★ lipschitzAt0_clampedSq

Clamped square surrogate for squared-loss contraction bounds

The clamped square is a globally Lipschitz surrogate for the squared map on a bounded prediction range. The basic loss squaredLoss lives in ML/Core/Losses; this separate surrogate file imports the Rademacher contraction interface and proves the analytic facts needed for squared-loss complexity bounds. The clipping itself is Causalean.Mathlib.Analysis.clipIcc (see Mathlib/Analysis/ClipInterval), whose contraction and boundedness lemmas are reused here.

On the band [-c, c], clampedSq c t agrees with ; globally, it is 2c-Lipschitz and fixes zero. This is the standard route for applying a Ledoux-Talagrand contraction bound to bounded squared-loss classes.

  • clampedSq_eq_sqclampedSq c t = t² whenever |t| ≤ c;
  • lipschitzAt0_clampedSqclampedSq c is LipschitzAt0 with constant 2c for c ≥ 0.
def clampedSq reviewed
Causalean.ML

The square of the projection of t onto [-c, c]: a globally Lipschitz surrogate that agrees with t ↦ t² on [-c, c].

Definition (Lean source)
noncomputable def clampedSq (c t : ℝ) : ℝ := (clipIcc (-c) c t) ^ 2
lemma clampedSq_eq_sq reviewed
Causalean.ML

On the band where t lies within c in absolute value, the clamped square clampedSq c t equals the genuine square .

Formal statement
c t :
ht :
|t| ≤ c
clampedSq c t = t ^ 2
Proof (Lean source)
lemma clampedSq_eq_sq {c t : ℝ} (ht : |t| ≤ c) : clampedSq c t = t ^ 2 := by rw [clampedSq, clipIcc_neg_eq_self ht]
Causalean.ML.clampedSq_eq_sq · Causalean/ML/Surrogate/ClampedSquare.lean:39 · uses clampedSq
lemma clampedSq_le_sq reviewed
Causalean.ML

For a nonnegative bound c, the clamped square clampedSq c t never exceeds , for every real t.

Formal statement
c :
hc :
0 ≤ c
t :
clampedSq c t ≤ c ^ 2
Proof (Lean source)
lemma clampedSq_le_sq {c : ℝ} (hc : 0 ≤ c) (t : ℝ) : clampedSq c t ≤ c ^ 2 := by have h := abs_clipIcc_neg_le hc t calc clampedSq c t = |clipIcc (-c) c t| ^ 2 := by rw [clampedSq, sq_abs] _ ≤ c ^ 2 := by gcongr
Causalean.ML.clampedSq_le_sq · Causalean/ML/Surrogate/ClampedSquare.lean:47 · uses clampedSq
lemma lipschitzAt0_clampedSq reviewed
Causalean.ML

For a nonnegative bound c, the clamped square clampedSq c is Lipschitz at 0 with constant 2c: it fixes 0 and is globally 2c-Lipschitz.

Formal statement
c :
hc :
0 ≤ c
Proof (Lean source)
lemma lipschitzAt0_clampedSq {c : ℝ} (hc : 0 ≤ c) : LipschitzAt0 (clampedSq c) (2 * c) := by refine ⟨?_, ?_⟩ · rw [clampedSq, clipIcc_neg_eq_self (by simpa using hc)] ring · intro x y have hclamp := abs_clipIcc_sub_clipIcc_le (-c) c x y have hfac : clampedSq c x - clampedSq c y = (clipIcc (-c) c x - clipIcc (-c) c y) * (clipIcc (-c) c x + clipIcc (-c) c y) := by simp only [clampedSq]; ring have hsum : |clipIcc (-c) c x + clipIcc (-c) c y| ≤ 2 * c := by have htri := abs_add_le (clipIcc (-c) c x) (clipIcc (-c) c y) have hcc := add_le_add (abs_clipIcc_neg_le hc x) (abs_clipIcc_neg_le hc y) linarith rw [hfac, abs_mul] have hmul : |clipIcc (-c) c x - clipIcc (-c) c y| * |clipIcc (-c) c x + clipIcc (-c) c y| ≤ |x - y| * (2 * c) := mul_le_mul hclamp hsum (abs_nonneg _) (abs_nonneg _) rw [show (2 : ℝ) * c * |x - y| = |x - y| * (2 * c) from by ring] exact hmul
2 supporting declarations (lemmas, instances)
Generic­ERM 3 core · 1 supporting This file defines ProperBinaryLoss and StrictProperBinaryLoss for losses L q b, where q is a predicted probability and b is a binary label. ★ ProperBinaryLoss★ properLoss_population_minimizer_recovers_eta

Proper binary losses and population risk

This file defines ProperBinaryLoss and StrictProperBinaryLoss for losses L q b, where q is a predicted probability and b is a binary label. A proper loss is minimized pointwise at the true probability η; a strictly proper loss has η as its unique [0,1] minimizer.

The theorem properLoss_population_risk_le integrates the pointwise proper-loss inequality, showing that predicting η has no larger conditional-risk integral than any measurable [0,1]-valued comparator. The theorem properLoss_population_minimizer_recovers_eta proves the corresponding identification statement for strictly proper losses: any population minimizer equals the true conditional probability almost everywhere.

def ProperBinaryLoss reviewed
Causalean.ML

A binary loss L : ℝ → Bool → ℝ is proper: for every true probability η ∈ [0,1], the conditional expected loss q ↦ η·L q true + (1−η)·L q false is minimized over [0,1] at q = η.

Definition (Lean source)
def ProperBinaryLoss (L : ℝ → Bool → ℝ) : Prop := ∀ η ∈ Icc (0 : ℝ) 1, IsMinOn (fun q => η * L q true + (1 - η) * L q false) (Icc (0 : ℝ) 1) η
Causalean.ML.ProperBinaryLoss · Causalean/ML/Surrogate/GenericERM.lean:28
def StrictProperBinaryLoss reviewed
Causalean.ML

A binary loss is strictly proper when it is proper and the true probability is the unique [0,1] minimizer of the conditional expected loss.

Definition (Lean source)
def StrictProperBinaryLoss (L : ℝ → Bool → ℝ) : Prop := ProperBinaryLoss L ∧ ∀ η ∈ Icc (0 : ℝ) 1, ∀ q ∈ Icc (0 : ℝ) 1, η * L q true + (1 - η) * L q false = η * L η true + (1 - η) * L η false → q = η
Causalean.ML.StrictProperBinaryLoss · Causalean/ML/Surrogate/GenericERM.lean:35
theorem properLoss_population_minimizer_recovers_eta reviewed
Causalean.ML

Strictly proper population minimizers recover the regression function. For a strictly proper binary loss L on a measure space PX, with the true conditional probability η taking values in [0,1] and a candidate prediction rule q also taking values in [0,1], if q minimizes the population conditional risk over every [0,1]-valued prediction rule and the conditional risks of η and q are both integrable, then q equals η almost everywhere.

Formal statement
L :
ℝ → Bool → ℝ
PX :
η :
X → ℝ
:
∀ x, η x ∈ Icc (0 : ℝ) 1
q :
X → ℝ
hq :
∀ x, q x ∈ Icc (0 : ℝ) 1
hmin :
IsMinOn (fun r : X → ℝ => ∫ x, (η x * L (r x) true + (1 - η x) * L (r x) false) ∂PX) {r : X → ℝ | ∀ x, r x ∈ Icc (0 : ℝ) 1} q
hint_η :
Integrable (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) PX
hint_q :
Integrable (fun x => η x * L (q x) true + (1 - η x) * L (q x) false) PX
q =ᵐ[PX] η
Proof (Lean source)
theorem properLoss_population_minimizer_recovers_eta {L : ℝ → Bool → ℝ} (hstrict : StrictProperBinaryLoss L) {PX : Measure X} (η : X → ℝ) (hη : ∀ x, η x ∈ Icc (0 : ℝ) 1) (q : X → ℝ) (hq : ∀ x, q x ∈ Icc (0 : ℝ) 1) (hmin : IsMinOn (fun r : X → ℝ => ∫ x, (η x * L (r x) true + (1 - η x) * L (r x) false) ∂PX) {r : X → ℝ | ∀ x, r x ∈ Icc (0 : ℝ) 1} q) (hint_η : Integrable (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) PX) (hint_q : Integrable (fun x => η x * L (q x) true + (1 - η x) * L (q x) false) PX) : q =ᵐ[PX] η := by have hη_le_q : ∫ x, (η x * L (η x) true + (1 - η x) * L (η x) false) ∂PX ≤ ∫ x, (η x * L (q x) true + (1 - η x) * L (q x) false) ∂PX := properLoss_population_risk_le hstrict.1 η hη q hq hint_η hint_q have hq_le_η : ∫ x, (η x * L (q x) true + (1 - η x) * L (q x) false) ∂PX ≤ ∫ x, (η x * L (η x) true + (1 - η x) * L (η x) false) ∂PX := (isMinOn_iff.mp hmin) η hη have hintegral_eq : ∫ x, (η x * L (η x) true + (1 - η x) * L (η x) false) ∂PX = ∫ x, (η x * L (q x) true + (1 - η x) * L (q x) false) ∂PX := le_antisymm hη_le_q hq_le_η have hrisk_le : (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) ≤ᵐ[PX] fun x => η x * L (q x) true + (1 - η x) * L (q x) false := Filter.Eventually.of_forall fun x => (hstrict.1 (η x) (hη x)) (hq x) have hrisk_eq : (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) =ᵐ[PX] fun x => η x * L (q x) true + (1 - η x) * L (q x) false := (integral_eq_iff_of_ae_le hint_η hint_q hrisk_le).1 hintegral_eq exact hrisk_eq.mono fun x hx => by exact hstrict.2 (η x) (hη x) (q x) (hq x) hx.symm
Causalean.ML.properLoss_population_minimizer_recovers_eta · Causalean/ML/Surrogate/GenericERM.lean:61 · uses StrictProperBinaryLoss
1 supporting declaration (lemmas, instances)
  • properLoss_population_risk_le theorem — Proper-loss integrated risk inequality. For a proper binary loss, the integral of the conditional risk obtained by predicting the true conditional probability is no larger than the corresponding integral for any pointwise [0,1]-valued comparator. The hypotheses keep both conditional-risk integrands integrable.
    L :
    ℝ → Bool → ℝ
    hproper :
    PX :
    η :
    X → ℝ
    :
    ∀ x, η x ∈ Icc (0 : ℝ) 1
    q :
    X → ℝ
    hq :
    ∀ x, q x ∈ Icc (0 : ℝ) 1
    hint_η :
    Integrable (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) PX
    hint_q :
    Integrable (fun x => η x * L (q x) true + (1 - η x) * L (q x) false) PX
    ∫ x, (η x * L (η x) true + (1 - η x) * L (η x) false) ∂PX
    ≤ ∫ x, (η x * L (q x) true + (1 - η x) * L (q x) false) ∂PX
    Proof (Lean source)
    theorem properLoss_population_risk_le {L : ℝ → Bool → ℝ} (hproper : ProperBinaryLoss L) {PX : Measure X} (η : X → ℝ) (hη : ∀ x, η x ∈ Icc (0 : ℝ) 1) (q : X → ℝ) (hq : ∀ x, q x ∈ Icc (0 : ℝ) 1) (hint_η : Integrable (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) PX) (hint_q : Integrable (fun x => η x * L (q x) true + (1 - η x) * L (q x) false) PX) : ∫ x, (η x * L (η x) true + (1 - η x) * L (η x) false) ∂PX ≤ ∫ x, (η x * L (q x) true + (1 - η x) * L (q x) false) ∂PX := by exact integral_mono hint_η hint_q (fun x => by exact (hproper (η x) (hη x)) (hq x))
    Causalean.ML.properLoss_population_risk_le · Causalean/ML/Surrogate/GenericERM.lean:45