ML.Binary

Roll-up of the logistic part of Causalean.ML: convexity and compact-set existence for empirical logistic risk, pointwise Fisher consistency of the Bernoulli cross-entropy loss, and the root-n L² estimation rate for an L²

Fisher­Consistency 2 core · 0 supporting The Bernoulli cross-entropy bernoulliCE η q = −η log q − (1−η) log(1−q) is minimized over q ∈ [0,1] exactly at q = η. ★ bernoulliCE_isMinOn

Fisher consistency of the logistic cross-entropy loss

The Bernoulli cross-entropy bernoulliCE η q = −η log q − (1−η) log(1−q) is minimized over q ∈ [0,1] exactly at q = η. This is the pointwise heart of Fisher consistency: the population log-loss minimizer recovers the true conditional probability η(x) = P(Y = 1 ∣ X = x).

def bernoulliCE reviewed
Causalean.ML

The Bernoulli cross-entropy of predicting probability q when the true probability is η.

Definition (Lean source)
noncomputable def bernoulliCE (η q : ℝ) : ℝ := -η * log q - (1 - η) * log (1 - q)
theorem bernoulliCE_isMinOn reviewed
Causalean.ML

For a true probability η strictly between 0 and 1, the Bernoulli cross-entropy q ↦ bernoulliCE η q attains its minimum over the open interval (0,1) exactly at the truth q = η.

Formal statement
η :
:
η ∈ Ioo (0 : ℝ) 1
IsMinOn (fun q : ℝ => bernoulliCE η q) (Ioo (0 : ℝ) 1) η
Proof (Lean source)
theorem bernoulliCE_isMinOn {η : ℝ} (hη : η ∈ Ioo (0 : ℝ) 1) : IsMinOn (fun q : ℝ => bernoulliCE η q) (Ioo (0 : ℝ) 1) η := by rw [isMinOn_iff] intro q hq rcases hη with ⟨hη0, hη1⟩ rcases hq with ⟨hq0, hq1⟩ have hη1pos : 0 < 1 - η := sub_pos.mpr hη1 have hq1pos : 0 < 1 - q := sub_pos.mpr hq1 have hlog1 : log q - log η ≤ q / η - 1 := by simpa [Real.log_div hq0.ne' hη0.ne'] using (Real.log_le_sub_one_of_pos (div_pos hq0 hη0)) have hineq1 : η * (log q - log η) ≤ q - η := by have hmul := mul_le_mul_of_nonneg_left hlog1 hη0.le have hrhs : η * (q / η - 1) = q - η := by field_simp [hη0.ne'] simpa [hrhs] using hmul have hlog2 : log (1 - q) - log (1 - η) ≤ (1 - q) / (1 - η) - 1 := by simpa [Real.log_div hq1pos.ne' hη1pos.ne'] using (Real.log_le_sub_one_of_pos (div_pos hq1pos hη1pos)) have hineq2 : (1 - η) * (log (1 - q) - log (1 - η)) ≤ η - q := by have hmul := mul_le_mul_of_nonneg_left hlog2 hη1pos.le have hrhs : (1 - η) * ((1 - q) / (1 - η) - 1) = η - q := by field_simp [hη1pos.ne'] ring simpa [hrhs] using hmul have hsum : η * log q + (1 - η) * log (1 - q) ≤ η * log η + (1 - η) * log (1 - η) := by nlinarith [hineq1, hineq2] unfold bernoulliCE nlinarith
Causalean.ML.bernoulliCE_isMinOn · Causalean/ML/Binary/FisherConsistency.lean:24 · uses bernoulliCE
Logistic 3 core · 3 supporting Binary logistic regression with score ⟪β, x⟫ and the score-space log-loss logisticScoreLoss. ★ convexOn_logisticEmpRisk★ logistic_exists_minimizer_on_compact

Logistic regression — convexity and existence

Binary logistic regression with score ⟪β, x⟫ and the score-space log-loss logisticScoreLoss. This file proves that the score-space loss and the empirical logistic risk are convex, and that an empirical-risk minimizer exists on any nonempty compact parameter set.

def logisticEmpRisk reviewed
Causalean.ML

The empirical logistic risk at coefficient β: average score-space log-loss over the sample Z.

Definition (Lean source)
noncomputable def logisticEmpRisk (Z : ι → E × Bool) (β : E) : ℝ := (Fintype.card ι : ℝ)⁻¹ * ∑ i, logisticScoreLoss (Z i).2 (inner ℝ β (Z i).1)
Causalean.ML.logisticEmpRisk · Causalean/ML/Binary/Logistic.lean:47
theorem convexOn_logisticEmpRisk reviewed
Causalean.ML

For any finite sample of feature–label pairs Z, the empirical logistic risk, as a function of the coefficient, is convex.

Formal statement
Z :
ι → E × Bool
Proof (Lean source)
theorem convexOn_logisticEmpRisk (Z : ι → E × Bool) : ConvexOnuniv (logisticEmpRisk Z) := by classical unfold logisticEmpRisk have hsummand : ∀ i : ι, ConvexOnuniv (fun β : E => logisticScoreLoss (Z i).2 (inner ℝ β (Z i).1)) := by intro i exact convexOn_comp_inner (convexOn_logisticScoreLoss (Z i).2) (Z i).1 have hfin : ∀ t : Finset ι, ConvexOnuniv (fun β : E => t.sum fun i => logisticScoreLoss (Z i).2 (inner ℝ β (Z i).1)) := by intro t induction t using Finset.induction_on with | empty => simpa using (convexOn_const (𝕜 := ℝ) (E := E) (β := ℝ) (s := univ) (0 : ℝ) convex_univ) | insert i t hi ht => simp only [Finset.sum_insert hi] exact (hsummand i).add ht simpa [smul_eq_mul] using (hfin univ).smul (inv_nonneg.mpr (Nat.cast_nonneg (card ι)))
Causalean.ML.convexOn_logisticEmpRisk · Causalean/ML/Binary/Logistic.lean:78 · uses logisticEmpRisk
theorem logistic_exists_minimizer_on_compact reviewed
Causalean.ML

For any labeled sample Z and a parameter set Θset that is nonempty and compact, the empirical logistic risk attains its minimum over Θset at some parameter βhat in Θset.

Formal statement
Z :
ι → E × Bool
Θset :
Set E
hne :
Θset.Nonempty
hcompact :
IsCompact Θset
∃ βhat ∈ Θset, IsMinOn (logisticEmpRisk Z) Θset βhat
Proof (Lean source)
theorem logistic_exists_minimizer_on_compact (Z : ι → E × Bool) {Θset : Set E} (hne : Θset.Nonempty) (hcompact : IsCompact Θset) : ∃ βhat ∈ Θset, IsMinOn (logisticEmpRisk Z) Θset βhat := exists_isMinOn_of_isCompact hne hcompact (continuous_logisticEmpRisk Z).continuousOn
Causalean.ML.logistic_exists_minimizer_on_compact · Causalean/ML/Binary/Logistic.lean:124 · uses logisticEmpRisk
3 supporting declarations (lemmas, instances)
Rate 4 core · 3 supporting The L²-penalized logistic quasi-score M-estimator and its root-n L²-estimation rate toward the penalized population target. ★ IsPopulationRegLogistic★ regLogistic_achievesL2Rate

L²-regularized logistic regression — estimation rate (root-n)

The L²-penalized logistic quasi-score M-estimator and its root-n L²-estimation rate toward the penalized population target. The response coordinate is real-valued in this file, so the result is a logistic quasi-score rate rather than a zero-one-only binary model. This is the binary-response analogue of the ridge rate (ML/Ridge/Rate.lean): the λ‖β‖² penalty makes the penalized objective globally -strongly convex, so — exactly as the ridge λI made the Gram positive definite — the coefficient error is controlled by a strong-convexity basic inequality instead of a closed-form inverse.

Crux (this file): with β̂ₙ solving the empirical penalized first-order condition ∇ₙ(β̂ₙ) = 0 and β⋆ the population FOC point, strong monotonicity of the gradient map (the logistic part is monotone since σ is increasing; the penalty contributes 2λ·id) gives 2λ‖β̂ₙ − β⋆‖ ≤ ∑ₖ |∇ₙ(β⋆)ₖ|, and the empirical gradient at β⋆ is a centered i.i.d. mean ⇒ O_p(n^{-1/2}). The predictor rate then follows from the 1/4-Lipschitz σ and the shared linear-predictor L² bound eLpNorm_predictor_sub_le.

def regLogisticGrad reviewed
Causalean.ML

Empirical penalized-logistic gradient at β (coordinate form): ∇ₙ(β)ₖ = n⁻¹ Σ_{i<n} (σ⟨β,φᵢ⟩ − yᵢ) φᵢₖ + 2λ βₖ.

Definition (Lean source)
noncomputable def regLogisticGrad (φ : FeatureMap γ K) (Z : ℕ → Ω → γ × ℝ) (lam : ℝ) (n : ℕ) (ω : Ω) (β : K → ℝ) : K → ℝ := fun k => (n : ℝ)⁻¹ * (∑ i ∈ range n, (sigmoid (∑ j, β j * φ.φ (Z i ω).1 j) - (Z i ω).2) * φ.φ (Z i ω).1 k) + 2 * lam * β k
Causalean.ML.regLogisticGrad · Causalean/ML/Binary/Rate.lean:35 · uses FeatureMap
def IsPopulationRegLogistic reviewed
Causalean.ML

The penalized population first-order condition at β⋆: E[(σ⟨β⋆,φ⟩ − Y) φₖ] + 2λ β⋆ₖ = 0 for every feature k.

Definition (Lean source)
def IsPopulationRegLogistic (P : Measure (γ × ℝ)) (φ : FeatureMap γ K) (lam : ℝ) (βstar : K → ℝ) : Prop := ∀ k, (∫ z, (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k ∂P) + 2 * lam * βstar k = 0
Causalean.ML.IsPopulationRegLogistic · Causalean/ML/Binary/Rate.lean:43 · uses FeatureMap
def logisticPredictor reviewed
Causalean.ML

The logistic predictor x ↦ σ(⟨β, φ(x)⟩) (the fitted conditional probability).

Definition (Lean source)
noncomputable def logisticPredictor (φ : FeatureMap γ K) (β : K → ℝ) : γ → ℝ := fun x => sigmoid (∑ k, β k * φ.φ x k)
Causalean.ML.logisticPredictor · Causalean/ML/Binary/Rate.lean:50 · uses FeatureMap
theorem regLogistic_achievesL2Rate reviewed
Causalean.ML

Regularized-logistic root-n estimation rate. For a strictly positive regularization weight lam, suppose βstar solves the penalized population first-order condition for the logistic quasi-score under the feature map φ and law P, and that for every sample size n and outcome ω, the fitted coefficients βhat n ω solve the corresponding empirical penalized first-order condition on the i.i.d. sample S. Suppose further that every feature coordinate is measurable, that the fourth moment of the squared feature norm is integrable under P, and that each coordinate of the population logistic score at βstar is square-integrable under P. Then the fitted logistic predictor σ(⟨βhat n ω, φ⟩) achieves the L²-rate n^{-1/2} toward the population target predictor σ(⟨βstar, φ⟩), under P and the sampling law μ. Assembled from the coefficient rate, the 1/4-Lipschitz σ, and the shared linear-predictor L² bound.

Formal statement
φ :
P :
S :
IIDSample Ω (γ × ℝ) μ P
lam :
hlam :
0 < lam
βstar :
K → ℝ
βhat :
ℕ → Ω → K → ℝ
hpop :
IsPopulationRegLogistic P φ lam βstar
hFOC :
∀ n ω, regLogisticGrad φ S.Z lam n ω (βhat n ω) = 0
:
∀ k, Measurable (fun x => φ.φ x k)
h4 :
Integrable (fun z => (∑ k, (φ.φ z.1 k) ^ 2) ^ 2) P
hscore :
∀ k, MemLp (fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k) 2 P
AchievesL2Rate (fun n ω => logisticPredictor φ (βhat n ω)) (logisticPredictor φ βstar) P (fun n => (sqrt (n : ℝ))⁻¹) μ
Proof (Lean source)
theorem regLogistic_achievesL2Rate (φ : FeatureMap γ K) (P : Measure (γ × ℝ)) [IsProbabilityMeasure P] (S : IIDSample Ω (γ × ℝ) μ P) [IsProbabilityMeasure μ] {lam : ℝ} (hlam : 0 < lam) (βstar : K → ℝ) (βhat : ℕ → Ω → K → ℝ) (hpop : IsPopulationRegLogistic P φ lam βstar) (hFOC : ∀ n ω, regLogisticGrad φ S.Z lam n ω (βhat n ω) = 0) (hφ : ∀ k, Measurable (fun x => φ.φ x k)) (h4 : Integrable (fun z => (∑ k, (φ.φ z.1 k) ^ 2) ^ 2) P) (hscore : ∀ k, MemLp (fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k) 2 P) : AchievesL2Rate (fun n ω => logisticPredictor φ (βhat n ω)) (logisticPredictor φ βstar) P (fun n => (sqrt (n : ℝ))⁻¹) μ := by classical rcases eLpNorm_predictor_sub_le φ P hφ h4 βstar with ⟨C, hC_nonneg, hC_bound⟩ have hcoef := regLogisticCoef_isBigOp φ P S hlam βstar βhat hpop hFOC hφ hscore let D : ℝ := (1 / 4 : ℝ) * C have hD_nonneg : 0 ≤ D := by dsimp [D] exact mul_nonneg (by norm_num) hC_nonneg have hpred_bound : ∀ n ω, (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal ≤ D * ‖βhat n ω - βstar‖ := by intro n ω let β : K → ℝ := βhat n ω let linDiff : γ → ℝ := fun x => (∑ k, β k * φ.φ x k) - ∑ k, βstar k * φ.φ x k have hlin_mem := linear_predictor_sub_memLp φ P hφ h4 β βstar have hlin_ne_top : eLpNorm linDiff 2 (P.map fst) ≠ ⊤ := by simpa [linDiff] using hlin_mem.eLpNorm_ne_top have hscale_ne_top : eLpNorm ((1 / 4 : ℝ) • linDiff) 2 (P.map fst) ≠ ⊤ := by rw [eLpNorm_const_smul] exact ENNReal.mul_ne_top (by simp) hlin_ne_top have hmono : eLpNorm (fun x => logisticPredictor φ β x - logisticPredictor φ βstar x) 2 (P.map fst) ≤ eLpNorm ((1 / 4 : ℝ) • linDiff) 2 (P.map fst) := by refine eLpNorm_mono (μ := P.map fst) (p := 2) (fun x => ?_) rw [Real.norm_eq_abs, Real.norm_eq_abs] dsimp [logisticPredictor, linDiff] have h := sigmoid_lipschitz_quarter.dist_le_mul (∑ k, β k * φ.φ x k) (∑ k, βstar k * φ.φ x k) simpa [Real.dist_eq, abs_sub_comm, div_eq_mul_inv] using h have hsig_le : (eLpNorm (fun x => logisticPredictor φ β x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal ≤ (1 / 4 : ℝ) * (eLpNorm linDiff 2 (P.map fst)).toReal := by calc (eLpNorm (fun x => logisticPredictor φ β x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal ≤ (eLpNorm ((1 / 4 : ℝ) • linDiff) 2 (P.map fst)).toReal := ENNReal.toReal_mono hscale_ne_top hmono _ = (1 / 4 : ℝ) * (eLpNorm linDiff 2 (P.map fst)).toReal := by rw [eLpNorm_const_smul] rw [ENNReal.toReal_mul] · norm_num [Real.norm_eq_abs] have hlin_bound : (eLpNorm linDiff 2 (P.map fst)).toReal ≤ C * ‖β - βstar‖ := by simpa [linDiff, β] using hC_bound β dsimp [D] nlinarith have hpred_finite : ∀ n ω, eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst) ≠ ⊤ := by intro n ω let β : K → ℝ := βhat n ω let linDiff : γ → ℝ := fun x => (∑ k, β k * φ.φ x k) - ∑ k, βstar k * φ.φ x k have hlin_mem := linear_predictor_sub_memLp φ P hφ h4 β βstar have hlin_ne_top : eLpNorm linDiff 2 (P.map fst) ≠ ⊤ := by simpa [linDiff] using hlin_mem.eLpNorm_ne_top have hscale_ne_top : eLpNorm ((1 / 4 : ℝ) • linDiff) 2 (P.map fst) ≠ ⊤ := by rw [eLpNorm_const_smul] exact ENNReal.mul_ne_top (by simp) hlin_ne_top have hmono : eLpNorm (fun x => logisticPredictor φ β x - logisticPredictor φ βstar x) 2 (P.map fst) ≤ eLpNorm ((1 / 4 : ℝ) • linDiff) 2 (P.map fst) := by refine eLpNorm_mono (μ := P.map fst) (p := 2) (fun x => ?_) rw [Real.norm_eq_abs, Real.norm_eq_abs] dsimp [logisticPredictor, linDiff] have h := sigmoid_lipschitz_quarter.dist_le_mul (∑ k, β k * φ.φ x k) (∑ k, βstar k * φ.φ x k) simpa [Real.dist_eq, abs_sub_comm, div_eq_mul_inv] using h exact ne_of_lt (lt_of_le_of_lt hmono (lt_top_iff_ne_top.mpr hscale_ne_top)) unfold AchievesL2Rate constructor · exact hpred_finite intro ε hε rcases hcoef ε hε with ⟨M0, hM0⟩ let M : ℝ := max M0 0 have hM0_le_M : M0 ≤ M := le_max_left M0 0 have hM_nonneg : 0 ≤ M := le_max_right M0 0 refine ⟨D * M, ?_⟩ have hlim_M : limsup (fun n : ℕ => μ {ω | M * (sqrt (n : ℝ))⁻¹ < |‖βhat n ω - βstar‖|}) atTopofReal ε := by refine le_trans (Filter.limsup_le_limsup (Filter.Eventually.of_forall ?_)) hM0 intro n apply measure_mono intro ω hω have hr_nonneg : 0 ≤ (sqrt (n : ℝ))⁻¹ := inv_nonneg.mpr (Real.sqrt_nonneg _) exact lt_of_le_of_lt (mul_le_mul_of_nonneg_right hM0_le_M hr_nonneg) hω refine le_trans (Filter.limsup_le_limsup (Filter.Eventually.of_forall ?_)) hlim_M intro n apply measure_mono intro ω hω by_cases hD_zero : D = 0 · have hpred_le_zero : (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal ≤ 0 := by simpa [hD_zero] using hpred_bound n ω have hpred_nonneg : 0 ≤ (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal := ENNReal.toReal_nonneg have hpred_abs : |(eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal| = 0 := by rw [abs_of_nonneg hpred_nonneg] exact le_antisymm hpred_le_zero hpred_nonneg rw [hD_zero, zero_mul, zero_mul] at hω have hpred_abs' : |(fun n ω => (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal) n ω| = 0 := by simpa using hpred_abs exfalso have hωlt : 0 < |(fun n ω => (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal) n ω| := by simpa using hω rw [hpred_abs'] at hωlt exact (lt_irrefl (0 : ℝ)) hωlt · have hD_pos : 0 < D := lt_of_le_of_ne hD_nonneg (Ne.symm hD_zero) have hpred_bound' : (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal ≤ D * ‖βhat n ω - βstar‖ := hpred_bound n ω have hpred_nonneg : 0 ≤ (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal := ENNReal.toReal_nonneg have hnorm_nonneg : 0 ≤ ‖βhat n ω - βstar‖ := norm_nonneg _ have hlt : D * (M * (sqrt (n : ℝ))⁻¹) < D * ‖βhat n ω - βstar‖ := by calc D * (M * (sqrt (n : ℝ))⁻¹) = (D * M) * (sqrt (n : ℝ))⁻¹ := by ring _ < |(eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal| := hω _ = (eLpNorm (fun x => logisticPredictor φ (βhat n ω) x - logisticPredictor φ βstar x) 2 (P.map fst)).toReal := by rw [abs_of_nonneg hpred_nonneg] _ ≤ D * ‖βhat n ω - βstar‖ := hpred_bound' have hlt' : M * (sqrt (n : ℝ))⁻¹ < ‖βhat n ω - βstar‖ := by nlinarith [hD_pos, hlt] simpa [abs_of_nonneg hnorm_nonneg] using hlt'
3 supporting declarations (lemmas, instances)
  • regLogistic_basic_inequality theorem — Strong-convexity basic inequality (deterministic). If β̂ solves the empirical penalized FOC ∇ₙ(β̂) = 0 and λ > 0, the coefficient error is controlled by the empirical gradient at the target: 2λ‖β̂ − β⋆‖ ≤ ∑ₖ |∇ₙ(β⋆)ₖ|.
    φ :
    Z :
    ℕ → Ω → γ × ℝ
    lam :
    hlam :
    0 < lam
    βstar :
    K → ℝ
    n :
    ω :
    Ω
    βhat :
    K → ℝ
    hFOC :
    regLogisticGrad φ Z lam n ω βhat = 0
    2 * lam * ‖βhat - βstar‖ ≤ ∑ k, |regLogisticGrad φ Z lam n ω βstar k|
    Proof (Lean source)
    theorem regLogistic_basic_inequality (φ : FeatureMap γ K) (Z : ℕ → Ω → γ × ℝ) {lam : ℝ} (hlam : 0 < lam) (βstar : K → ℝ) (n : ℕ) (ω : Ω) {βhat : K → ℝ} (hFOC : regLogisticGrad φ Z lam n ω βhat = 0) : 2 * lam * ‖βhat - βstar‖ ≤ ∑ k, |regLogisticGrad φ Z lam n ω βstar k| := by classical let δ : K → ℝ := βhat - βstar let lin : (K → ℝ) → ℕ → ℝ := fun β i => ∑ j, β j * φ.φ (Z i ω).1 j let S0 : ℝ := ∑ k, (regLogisticGrad φ Z lam n ω βhat k - regLogisticGrad φ Z lam n ω βstar k) * δ k let a : ℕ → ℝ := fun i => sigmoid (lin βhat i) - sigmoid (lin βstar i) let b : ℕ → K → ℝ := fun i k => φ.φ (Z i ω).1 k have hgrad_diff : ∀ k, regLogisticGrad φ Z lam n ω βhat k - regLogisticGrad φ Z lam n ω βstar k = (n : ℝ)⁻¹ * ∑ i ∈ range n, a i * b i k + 2 * lam * δ k := by intro k have hsum : (∑ i ∈ range n, (sigmoid (lin βhat i) - (Z i ω).2) * b i k) - (∑ i ∈ range n, (sigmoid (lin βstar i) - (Z i ω).2) * b i k) = ∑ i ∈ range n, a i * b i k := by rw [← Finset.sum_sub_distrib] refine Finset.sum_congr rfl ?_ intro i _ dsimp [a] ring dsimp [regLogisticGrad, lin, b] change (n : ℝ)⁻¹ * (∑ i ∈ range n, (sigmoid (lin βhat i) - (Z i ω).2) * b i k) + 2 * lam * βhat k - ((n : ℝ)⁻¹ * (∑ i ∈ range n, (sigmoid (lin βstar i) - (Z i ω).2) * b i k) + 2 * lam * βstar k) = (n : ℝ)⁻¹ * ∑ i ∈ range n, a i * b i k + 2 * lam * δ k rw [← hsum] dsimp [δ] ring_nf have hinner : ∀ i, ∑ k, b i k * δ k = lin βhat i - lin βstar i := by intro i dsimp [b, δ, lin] rw [← Finset.sum_sub_distrib] refine Finset.sum_congr rfl ?_ intro k _ ring have hsum_emp : ∑ k, ((n : ℝ)⁻¹ * ∑ i ∈ range n, a i * b i k) * δ k = (n : ℝ)⁻¹ * ∑ i ∈ range n, a i * (lin βhat i - lin βstar i) := by calc ∑ k, ((n : ℝ)⁻¹ * ∑ i ∈ range n, a i * b i k) * δ k = (n : ℝ)⁻¹ * ∑ k, (∑ i ∈ range n, a i * b i k) * δ k := by rw [Finset.mul_sum] refine Finset.sum_congr rfl ?_ intro k _ ring _ = (n : ℝ)⁻¹ * ∑ k, ∑ i ∈ range n, (a i * b i k) * δ k := by congr 1 refine Finset.sum_congr rfl ?_ intro k _ rw [Finset.sum_mul] _ = (n : ℝ)⁻¹ * ∑ i ∈ range n, ∑ k, (a i * b i k) * δ k := by congr 1 rw [Finset.sum_comm] _ = (n : ℝ)⁻¹ * ∑ i ∈ range n, a i * (lin βhat i - lin βstar i) := by congr 1 refine Finset.sum_congr rfl ?_ intro i _ rw [← hinner i, Finset.mul_sum] refine Finset.sum_congr rfl ?_ intro k _ ring have hS_eq : S0 = (n : ℝ)⁻¹ * ∑ i ∈ range n, (sigmoid (lin βhat i) - sigmoid (lin βstar i)) * (lin βhat i - lin βstar i) + 2 * lam * ∑ k, (δ k) ^ 2 := by calc S0 = ∑ k, (((n : ℝ)⁻¹ * ∑ i ∈ range n, a i * b i k + 2 * lam * δ k) * δ k) := by dsimp [S0] refine Finset.sum_congr rfl ?_ intro k _ rw [hgrad_diff] _ = ∑ k, ((n : ℝ)⁻¹ * ∑ i ∈ range n, a i * b i k) * δ k + ∑ k, (2 * lam * δ k) * δ k := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl ?_ intro k _ ring _ = (n : ℝ)⁻¹ * ∑ i ∈ range n, a i * (lin βhat i - lin βstar i) + 2 * lam * ∑ k, (δ k) ^ 2 := by rw [hsum_emp] congr 1 rw [Finset.mul_sum] refine Finset.sum_congr rfl ?_ intro k _ ring _ = (n : ℝ)⁻¹ * ∑ i ∈ range n, (sigmoid (lin βhat i) - sigmoid (lin βstar i)) * (lin βhat i - lin βstar i) + 2 * lam * ∑ k, (δ k) ^ 2 := rfl have hlog_nonneg : 0 ≤ (n : ℝ)⁻¹ * ∑ i ∈ range n, (sigmoid (lin βhat i) - sigmoid (lin βstar i)) * (lin βhat i - lin βstar i) := by exact mul_nonneg (inv_nonneg.mpr (Nat.cast_nonneg n)) (sum_nonneg fun i _ => monotone_mul_sub_nonneg Real.sigmoid_monotone (lin βhat i) (lin βstar i)) have hS_lower : 2 * lam * ∑ k, (δ k) ^ 2 ≤ S0 := by nlinarith [hS_eq, hlog_nonneg] have hS_grad : S0 = - ∑ k, regLogisticGrad φ Z lam n ω βstar k * δ k := by dsimp [S0, δ] simp [congrFun hFOC] have hneg_le_abs : - ∑ k, regLogisticGrad φ Z lam n ω βstar k * δ k ≤ ∑ k, |regLogisticGrad φ Z lam n ω βstar k| * |δ k| := by rw [← Finset.sum_neg_distrib] refine Finset.sum_le_sum ?_ intro k _ calc -(regLogisticGrad φ Z lam n ω βstar k * δ k) ≤ |regLogisticGrad φ Z lam n ω βstar k * δ k| := neg_le_abs _ _ = |regLogisticGrad φ Z lam n ω βstar k| * |δ k| := by rw [abs_mul] have hdot_bound : ∑ k, |regLogisticGrad φ Z lam n ω βstar k| * |δ k| ≤ (∑ k, |regLogisticGrad φ Z lam n ω βstar k|) * ‖δ‖ := by rw [Finset.sum_mul] refine Finset.sum_le_sum ?_ intro k _ have hcoord := norm_le_pi_norm δ k have habs : |δ k| ≤ ‖δ‖ := by simpa [Real.norm_eq_abs] using hcoord exact mul_le_mul_of_nonneg_left habs (abs_nonneg _) have hS_upper : S0 ≤ (∑ k, |regLogisticGrad φ Z lam n ω βstar k|) * ‖δ‖ := by calc S0 = - ∑ k, regLogisticGrad φ Z lam n ω βstar k * δ k := hS_grad _ ≤ ∑ k, |regLogisticGrad φ Z lam n ω βstar k| * |δ k| := hneg_le_abs _ ≤ (∑ k, |regLogisticGrad φ Z lam n ω βstar k|) * ‖δ‖ := hdot_bound have hquad : 2 * lam * ‖δ‖ ^ 2 ≤ (∑ k, |regLogisticGrad φ Z lam n ω βstar k|) * ‖δ‖ := by have hnormsq := pi_norm_sq_le_sum_sq δ have hleft : 2 * lam * ‖δ‖ ^ 2 ≤ 2 * lam * ∑ k, (δ k) ^ 2 := by exact mul_le_mul_of_nonneg_left hnormsq (by nlinarith) exact hleft.trans (hS_lower.trans hS_upper) by_cases hzero : ‖δ‖ = 0 · rw [show ‖βhat - βstar‖ = ‖δ‖ by rfl, hzero, mul_zero] exact sum_nonneg fun k _ => abs_nonneg _ · have hnorm_pos : 0 < ‖δ‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hzero) have hfinal : 2 * lam * ‖δ‖ ≤ ∑ k, |regLogisticGrad φ Z lam n ω βstar k| := by calc 2 * lam * ‖δ‖ = (2 * lam * ‖δ‖ ^ 2) / ‖δ‖ := by field_simp [hnorm_pos.ne'] _ ≤ ((∑ k, |regLogisticGrad φ Z lam n ω βstar k|) * ‖δ‖) / ‖δ‖ := by exact div_le_div_of_nonneg_right hquad hnorm_pos.le _ = ∑ k, |regLogisticGrad φ Z lam n ω βstar k| := by field_simp [hnorm_pos.ne'] simpa [δ] using hfinal
    Causalean.ML.regLogistic_basic_inequality · Causalean/ML/Binary/Rate.lean:143
  • regLogisticGrad_coord_isBigOp theorem — Each coordinate of the empirical penalized gradient at the population target is O_p(n^{-1/2}); the population score equations make the i.i.d. summands centered.
    φ :
    P :
    S :
    IIDSample Ω (γ × ℝ) μ P
    lam :
    βstar :
    K → ℝ
    hpop :
    IsPopulationRegLogistic P φ lam βstar
    :
    ∀ k, Measurable (fun x => φ.φ x k)
    hscore :
    ∀ k, MemLp (fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k) 2 P
    k :
    K
    IsBigOp (fun n ω => regLogisticGrad φ S.Z lam n ω βstar k) (fun n => (sqrt (n : ℝ))⁻¹) μ
    Proof (Lean source)
    theorem regLogisticGrad_coord_isBigOp (φ : FeatureMap γ K) (P : Measure (γ × ℝ)) [IsProbabilityMeasure P] (S : IIDSample Ω (γ × ℝ) μ P) [IsProbabilityMeasure μ] {lam : ℝ} (βstar : K → ℝ) (hpop : IsPopulationRegLogistic P φ lam βstar) (hφ : ∀ k, Measurable (fun x => φ.φ x k)) (hscore : ∀ k, MemLp (fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k) 2 P) (k : K) : IsBigOp (fun n ω => regLogisticGrad φ S.Z lam n ω βstar k) (fun n => (sqrt (n : ℝ))⁻¹) μ := by classical let g : γ × ℝ → ℝ := fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k have hφ_prod : ∀ k, Measurable (fun z : γ × ℝ => φ.φ z.1 k) := fun k => (hφ k).comp measurable_fst have hg_meas : Measurable g := by dsimp [g] have hlin : Measurable (fun z : γ × ℝ => ∑ j, βstar j * φ.φ z.1 j) := measurable_sum _ fun j _ => measurable_const.mul (hφ_prod j) exact ((continuous_sigmoid.measurable.comp hlin).sub measurable_snd).mul (hφ_prod k) have hcoord : (fun n ω => regLogisticGrad φ S.Z lam n ω βstar k) = (fun n ω => S.sampleMean g n ω - ∫ z, g z ∂P) := by funext n ω have hpopk : (∫ z, g z ∂P) + 2 * lam * βstar k = 0 := by simpa [g] using hpop k dsimp [regLogisticGrad, IIDSample.sampleMean, g] linarith have hk0 := S.sampleMean_sub_isBigOp hg_meas (by simpa [g] using hscore k) let A : ℝ := ∫ z, (g z) ^ 2 ∂P have hA_nonneg : 0 ≤ A := by dsimp [A] exact integral_nonneg fun z => sq_nonneg _ have hrate_le : ∀ n : ℕ, sqrt (A / (n : ℝ)) ≤ (sqrt A + 1) * (sqrt (n : ℝ))⁻¹ := by intro n calc sqrt (A / (n : ℝ)) = sqrt A * (sqrt (n : ℝ))⁻¹ := by rw [Real.sqrt_div hA_nonneg, div_eq_mul_inv] _ ≤ (sqrt A + 1) * (sqrt (n : ℝ))⁻¹ := by exact mul_le_mul_of_nonneg_right (by linarith [Real.sqrt_nonneg A]) (inv_nonneg.mpr (Real.sqrt_nonneg (n : ℝ))) have hk1 : IsBigOp (fun n ω => S.sampleMean g n ω - ∫ z, g z ∂P) (fun n => (sqrt A + 1) * (sqrt (n : ℝ))⁻¹) μ := by exact mono_rate (fun n => Real.sqrt_nonneg (A / (n : ℝ))) hrate_le hk0 have hk2 : IsBigOp (fun n ω => S.sampleMean g n ω - ∫ z, g z ∂P) (fun n => (sqrt (n : ℝ))⁻¹) μ := by exact scale_rate (rn := fun n => (sqrt (n : ℝ))⁻¹) (by linarith [Real.sqrt_nonneg A]) hk1 rw [hcoord] exact hk2
    Causalean.ML.regLogisticGrad_coord_isBigOp · Causalean/ML/Binary/Rate.lean:306
  • regLogisticCoef_isBigOp theorem — The regularized-logistic coefficient error is O_p(n^{-1/2}): the strong-convexity basic inequality converts the centered-gradient bound into a coefficient-error bound.
    φ :
    P :
    S :
    IIDSample Ω (γ × ℝ) μ P
    lam :
    hlam :
    0 < lam
    βstar :
    K → ℝ
    βhat :
    ℕ → Ω → K → ℝ
    hpop :
    IsPopulationRegLogistic P φ lam βstar
    hFOC :
    ∀ n ω, regLogisticGrad φ S.Z lam n ω (βhat n ω) = 0
    :
    ∀ k, Measurable (fun x => φ.φ x k)
    hscore :
    ∀ k, MemLp (fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k) 2 P
    IsBigOp (fun n ω => ‖βhat n ω - βstar‖) (fun n => (sqrt (n : ℝ))⁻¹) μ
    Proof (Lean source)
    theorem regLogisticCoef_isBigOp (φ : FeatureMap γ K) (P : Measure (γ × ℝ)) [IsProbabilityMeasure P] (S : IIDSample Ω (γ × ℝ) μ P) [IsProbabilityMeasure μ] {lam : ℝ} (hlam : 0 < lam) (βstar : K → ℝ) (βhat : ℕ → Ω → K → ℝ) (hpop : IsPopulationRegLogistic P φ lam βstar) (hFOC : ∀ n ω, regLogisticGrad φ S.Z lam n ω (βhat n ω) = 0) (hφ : ∀ k, Measurable (fun x => φ.φ x k)) (hscore : ∀ k, MemLp (fun z => (sigmoid (∑ j, βstar j * φ.φ z.1 j) - z.2) * φ.φ z.1 k) 2 P) : IsBigOp (fun n ω => ‖βhat n ω - βstar‖) (fun n => (sqrt (n : ℝ))⁻¹) μ := by classical let rn : ℕ → ℝ := fun n => (sqrt (n : ℝ))⁻¹ have hgrad_abs : ∀ k, IsBigOp (fun n ω => |regLogisticGrad φ S.Z lam n ω βstar k|) rn μ := by intro k simpa [IsBigOp, abs_abs, rn] using (regLogisticGrad_coord_isBigOp φ P S βstar hpop hφ hscore k) have hsum_abs : IsBigOp (fun n ω => ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k|) rn μ := by simpa using (IsBigOp.finset_sum (μ := μ) (s := (Finset.univ : Finset K)) (X := fun k n ω => |regLogisticGrad φ S.Z lam n ω βstar k|) (fun k _ => hgrad_abs k)) have hscaled : IsBigOp (fun n ω => (1 / (2 * lam)) * ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k|) rn μ := by exact IsBigOp.const_mul (μ := μ) (c := 1 / (2 * lam)) hsum_abs refine IsBigOp.of_abs_le (Xn := fun n ω => ‖βhat n ω - βstar‖) (Yn := fun n ω => (1 / (2 * lam)) * ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k|) ?_ hscaled intro n ω have hden_pos : 0 < 2 * lam := by nlinarith have hbound0 := regLogistic_basic_inequality φ S.Z hlam βstar n ω (hFOC n ω) have hsum_nonneg : 0 ≤ ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k| := sum_nonneg fun k _ => abs_nonneg _ have hscale_nonneg : 0 ≤ (1 / (2 * lam)) * ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k| := by exact mul_nonneg (le_of_lt (one_div_pos.mpr hden_pos)) hsum_nonneg rw [abs_of_nonneg (norm_nonneg _), abs_of_nonneg hscale_nonneg] calc ‖βhat n ω - βstar‖ = (2 * lam)⁻¹ * ((2 * lam) * ‖βhat n ω - βstar‖) := by field_simp [hden_pos.ne'] _ ≤ (2 * lam)⁻¹ * ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k| := by exact mul_le_mul_of_nonneg_left hbound0 (inv_nonneg.mpr hden_pos.le) _ = (1 / (2 * lam)) * ∑ k, |regLogisticGrad φ S.Z lam n ω βstar k| := by ring
    Causalean.ML.regLogisticCoef_isBigOp · Causalean/ML/Binary/Rate.lean:370