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 3 core · 3 supporting The clamped square is a globally Lipschitz surrogate for the squared map on a bounded prediction range. ★ clampedSq★ clampedSq_eq_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 t²; 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_sq — clampedSq c t = t² whenever |t| ≤ c;
  • lipschitzAt0_clampedSq — clampedSq c is LipschitzAt0 with constant 2c for c ≥ 0.
def clampedSq reviewed
Causalean.ML

The clamped-square surrogate controls squared loss globally by clipping to a symmetric interval and squaring. It uses a real clipping bound and real input, even when the nominal lower and upper endpoints are not ordered.

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

Clamped square agrees with ordinary square throughout the unclipped input band.

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:49 · uses clampedSq
lemma lipschitzAt0_clampedSq reviewed
Causalean.ML

Clamped square fixes zero and is globally twice-bound Lipschitz when the clipping bound is nonnegative.

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
3 supporting declarations (lemmas, instances)
Proper­Loss 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.

Gneiting--Raftery (2007), equation (1), uses the opposite convention of scores that are maximized; the definitions here reorient those scores as losses to minimize. Proper and strictly proper binary losses follow Reid--Williamson (2010), Section 3.1. Log loss requires the conditional probability to lie in the open interval (0,1) when finite real-valued risk, rather than an extended endpoint convention, is needed.

def ProperBinaryLoss reviewed
Causalean.ML

A proper binary loss makes truthful probability reports optimal: truth weakly minimizes conditional risk on the unit interval. The criterion applies to a real-valued binary probability loss.

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

A strictly proper binary loss makes truthful probability reporting uniquely optimal: the loss is proper, and equal conditional risk forces truth. It applies to a real-valued binary probability loss.

Definition (Lean source)
L :
ℝ → Bool → ℝ
StrictProperBinaryLoss L :
Prop
clause 2
η ∈ Set.Icc (0 : ℝ) 1 :
q ∈ Set.Icc (0 : ℝ) 1 :
η * L q true + (1 - η) * L q false = η * L η true + (1 - η) * L η false
q = η
Causalean.ML.StrictProperBinaryLoss · Causalean/ML/Surrogate/ProperLoss.lean:48
theorem properLoss_population_minimizer_recovers_eta reviewed
Causalean.ML

Strictly proper population minimizers recover the regression function. For a strictly proper binary loss under a population law, suppose the true conditional probability is measurable, [0,1]-valued almost everywhere, and has integrable conditional risk, while the candidate is measurable, [0,1]-valued almost everywhere, and has integrable risk. If the candidate minimizes over admissible competitors, then it equals the truth almost everywhere.

Formal statement
X :
Type u_1
shared
L :
ℝ → Bool → ℝ
PX :
η :
X → ℝ
hη_meas :
hη :
∀ᵐ x ∂PX, η x ∈ Icc (0 : ℝ) 1
q :
X → ℝ
hq_meas :
hq :
∀ᵐ x ∂PX, q x ∈ Icc (0 : ℝ) 1
hint_q :
Integrable (fun x => η x * L (q x) true + (1 - η x) * L (q x) false) PX
hmin :
IsMinOn (fun r : X → ℝ => ∫ x, (η x * L (r x) true + (1 - η x) * L (r x) false) ∂PX) {r : X → ℝ | Measurable r ∧ (∀ᵐ x ∂PX, r x ∈ Icc (0 : ℝ) 1) ∧ Integrable (fun x => η x * L (r x) true + (1 - η x) * L (r x) false) PX} q
hint_η :
Integrable (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) PX
q =ᵐ[PX] η
Proof (Lean source)
theorem properLoss_population_minimizer_recovers_eta {L : ℝ → Bool → ℝ} (hstrict : StrictProperBinaryLoss L) {PX : Measure X} (η : X → ℝ) (hη_meas : Measurable η) (hη : ∀ᵐ x ∂PX, η x ∈ Icc (0 : ℝ) 1) (q : X → ℝ) (hq_meas : Measurable q) (hq : ∀ᵐ x ∂PX, q x ∈ Icc (0 : ℝ) 1) (hint_q : Integrable (fun x => η x * L (q x) true + (1 - η x) * L (q x) false) PX) (hmin : IsMinOn (fun r : X → ℝ => ∫ x, (η x * L (r x) true + (1 - η x) * L (r x) false) ∂PX) {r : X → ℝ | Measurable r ∧ (∀ᵐ x ∂PX, r x ∈ Icc (0 : ℝ) 1) ∧ Integrable (fun x => η x * L (r x) true + (1 - η x) * L (r x) false) PX} q) (hint_η : Integrable (fun x => η x * L (η x) true + (1 - η x) * L (η x) false) PX) : q =ᵐ[PX] η := by have hq_admissible : q ∈ {r : X → ℝ | Measurable r ∧ (∀ᵐ x ∂PX, r x ∈ Icc (0 : ℝ) 1) ∧ Integrable (fun x => η x * L (r x) true + (1 - η x) * L (r x) false) PX} := ⟨hq_meas, hq, hint_q⟩ 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_admissible.2.1 hint_η hq_admissible.2.2 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η_meas, hη, hint_η⟩ 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 := by filter_upwards [hη, hq] with x hηx hqx exact (hstrict.1 (η x) hηx) hqx 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 filter_upwards [hrisk_eq, hη, hq] with x hx hηx hqx exact hstrict.2 (η x) hηx (q x) hqx hx.symm
Causalean.ML.properLoss_population_minimizer_recovers_eta · Causalean/ML/Surrogate/ProperLoss.lean:79 · uses StrictProperBinaryLoss
1 supporting declaration (lemmas, instances)
  • properLoss_population_risk_le theorem — Proper-loss integrated risk inequality. For a proper binary loss under a population law, let the true conditional probability and a comparator be [0,1]-valued almost everywhere, with integrable truthful and comparator conditional risks. Then truthful prediction has no larger integrated risk than the comparator.
    X :
    Type u_1
    shared
    L :
    ℝ → Bool → ℝ
    hproper :
    PX :
    η :
    X → ℝ
    hη :
    ∀ᵐ x ∂PX, η x ∈ Icc (0 : ℝ) 1
    q :
    X → ℝ
    hq :
    ∀ᵐ x ∂PX, 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 ∂PX, η x ∈ Icc (0 : ℝ) 1) (q : X → ℝ) (hq : ∀ᵐ x ∂PX, 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_ae hint_η hint_q <| by filter_upwards [hη, hq] with x hηx hqx exact (hproper (η x) hηx) hqx
    Causalean.ML.properLoss_population_risk_le · Causalean/ML/Surrogate/ProperLoss.lean:62