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 For a true probability strictly between zero and one, reporting that probability minimizes Bernoulli cross-entropy over the open unit interval. ★ bernoulliCE_isMinOn

Fisher consistency of the logistic cross-entropy loss

For a true probability strictly between zero and one, reporting that probability minimizes Bernoulli cross-entropy over the open unit interval. This is the pointwise optimality direction behind Fisher consistency. The theorem here does not assert uniqueness, and the open interval avoids the ambient convention that assigns a finite real value to the logarithm at zero.

def bernoulliCE reviewed
Causalean.ML

Bernoulli cross-entropy scores a predicted success probability against the true success probability by weighting the success and failure log losses.

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

Truth minimizes cross-entropy on the open unit interval when the true probability is strictly between zero and one.

Formal statement
η :
ℝ
hη :
η ∈ 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:31 · uses bernoulliCE
Logistic 3 core · 4 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

Empirical logistic risk is average logistic loss at coefficient--feature inner products. It scores a coefficient vector on feature--binary-outcome observations indexed by a finite sample set in a real inner-product feature space.

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

Empirical logistic risk is convex in the coefficient vector for every finite feature--label sample.

Formal statement
ι :
Type u_1
shared
E :
Type u_2
shared
Z :
ι → E × Bool
Proof (Lean source)
theorem convexOn_logisticEmpRisk (Z : ι → E × Bool) : ConvexOn ℝ univ (logisticEmpRisk Z) := by classical unfold logisticEmpRisk have hsummand : ∀ i : ι, ConvexOn ℝ univ (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 ι, ConvexOn ℝ univ (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:87 · uses logisticEmpRisk
theorem logistic_exists_minimizer_on_compact reviewed
Causalean.ML

Empirical logistic risk attains a constrained minimum for any labeled sample whenever the parameter set is nonempty and compact. Compactness prevents an optimizing coefficient sequence from escaping to infinity.

Formal statement
ι :
Type u_1
shared
E :
Type u_2
shared
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:134 · uses logisticEmpRisk
4 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 fixed-penalty population pseudo-true 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 fixed-penalty population pseudo-true target. This target is not in general the conditional response probability; such an identification needs additional model- specification or vanishing-penalty assumptions. 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 2λ-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

The empirical penalized-logistic gradient has average score--feature product plus penalty in each coordinate. It is computed from sample-indexed covariate--response observations at sample size, state, and penalty level for a coefficient vector and feature map on the sample-state, covariate, and finite feature-coordinate spaces.

Definition (Lean source)
Ω :
Type u_1
shared
γ :
Type u_2
shared
K :
Type u_3
shared
φ :
Z :
ℕ → Ω → γ × ℝ
lam :
ℝ
n :
ℕ
ω :
Ω
β :
K → ℝ
regLogisticGrad φ Z lam n ω β :
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:41 · uses FeatureMap
def IsPopulationRegLogistic reviewed
Causalean.ML

The penalized population logistic first-order condition requires expected score--feature product plus penalty to vanish coordinatewise. It evaluates a coefficient vector and a finite feature map at penalty level under a joint covariate--response law.

Definition (Lean source)
γ :
Type u_2
shared
K :
Type u_3
shared
P :
Measure (γ × ℝ)
φ :
lam :
ℝ
βstar :
K → ℝ
k :
IsPopulationRegLogistic P φ lam βstar :
Prop
(∫ 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:53 · uses FeatureMap
def logisticPredictor reviewed
Causalean.ML

The logistic predictor maps each covariate value to the logistic transform of its linear feature score. The score combines a coefficient vector with a finite feature map on the covariate space.

Definition (Lean source)
γ :
Type u_2
shared
K :
Type u_3
shared
φ :
β :
K → ℝ
logisticPredictor φ β :
γ → ℝ
fun x => sigmoid (∑ k, β k * φ.φ x k)
Causalean.ML.logisticPredictor · Causalean/ML/Binary/Rate.lean:62 · 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 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 μ. This fixed-penalty pseudo-true predictor is not asserted to equal the conditional response probability. Assembled from the coefficient rate, the 1/4-Lipschitz σ, and the shared linear-predictor L² bound.

Formal statement
Ω :
Type u_1
shared
γ :
Type u_2
shared
K :
Type u_3
shared
μ :
shared
φ :
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
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 : ℝ))⁻¹) μ
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 refine IsBigOp.of_abs_le (Yn := fun n ω => D * ‖βhat n ω - βstar‖) ?_ (IsBigOp.const_mul D hcoef) intro n ω rw [abs_of_nonneg ENNReal.toReal_nonneg, abs_of_nonneg (mul_nonneg hD_nonneg (norm_nonneg _))] exact hpred_bound n ω
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λ‖β̂ − β⋆‖ ≤ ∑ₖ |∇ₙ(β⋆)ₖ|.
    Ω :
    Type u_1
    shared
    γ :
    Type u_2
    shared
    K :
    Type u_3
    shared
    φ :
    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)) (Finset.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 Finset.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:158
  • 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.
    Ω :
    Type u_1
    shared
    γ :
    Type u_2
    shared
    K :
    Type u_3
    shared
    μ :
    shared
    φ :
    P :
    S :
    IIDSample Ω (γ × ℝ) μ P
    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 : ℝ))⁻¹) μ
    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 fun_prop 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 let A : ℝ := ∫ z, (g z) ^ 2 ∂P have hA_nonneg : 0 ≤ A := by dsimp [A] exact integral_nonneg fun z => sq_nonneg _ rw [hcoord] by_cases hA_pos : 0 < A · have hk0 := S.sampleMean_sub_isBigOp hg_meas (by simpa [g] using hscore k) (by simpa [A] using hA_pos) 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 hrate_le hk0 exact scale_rate (rn := fun n => (sqrt (n : ℝ))⁻¹) (by linarith [Real.sqrt_nonneg A]) hk1 · have hA_zero : A = 0 := le_antisymm (le_of_not_gt hA_pos) hA_nonneg intro δ hδ refine ⟨1, one_pos, ?_⟩ filter_upwards [Filter.eventually_gt_atTop (0 : ℕ)] with n hn have hsq := S.sampleMean_sub_sq_lintegral_le hg_meas (by simpa [g] using hscore k) hn have hlintegral_zero : ∫⁻ ω, ofReal ((S.sampleMean g n ω - ∫ z, g z ∂P) ^ 2) ∂μ = 0 := by apply le_antisymm · simpa [A, hA_zero] using hsq · exact bot_le have hae_sq : (fun ω => ofReal ((S.sampleMean g n ω - ∫ z, g z ∂P) ^ 2)) =ᵐ[μ] 0 := (lintegral_eq_zero_iff' (by fun_prop)).mp hlintegral_zero have hae_zero : (fun ω => S.sampleMean g n ω - ∫ z, g z ∂P) =ᵐ[μ] 0 := by filter_upwards [hae_sq] with ω hω simp only [Pi.zero_apply] at hω have hsquare_zero : (S.sampleMean g n ω - ∫ z, g z ∂P) ^ 2 = 0 := le_antisymm (ENNReal.ofReal_eq_zero.mp hω) (sq_nonneg _) exact sq_eq_zero_iff.mp hsquare_zero have hrate_pos : 0 < (sqrt (n : ℝ))⁻¹ := inv_pos.mpr (Real.sqrt_pos.mpr (by exact_mod_cast hn)) have hevent_zero : μ {ω | (1 : ℝ) * (sqrt (n : ℝ))⁻¹ ≤ ‖S.sampleMean g n ω - ∫ z, g z ∂P‖} = 0 := by rw [measure_eq_zero_iff_ae_notMem] filter_upwards [hae_zero] with ω hω simp [hω, not_le.mpr hrate_pos] calc μ {ω | (1 : ℝ) * (sqrt (n : ℝ))⁻¹ ≤ ‖S.sampleMean g n ω - ∫ z, g z ∂P‖} = 0 := hevent_zero _ ≤ δ := bot_le
    Causalean.ML.regLogisticGrad_coord_isBigOp · Causalean/ML/Binary/Rate.lean:321
  • 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.
    Ω :
    Type u_1
    shared
    γ :
    Type u_2
    shared
    K :
    Type u_3
    shared
    μ :
    shared
    φ :
    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
    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 : ℝ))⁻¹) μ
    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 only [IsBigOp, BoundedInProbability, Real.norm_eq_abs, abs_abs, rn] using (regLogisticGrad_coord_isBigOp φ P S βstar hpop hφ hscore k) have hrn_pos : ∀ᶠ n : ℕ in atTop, 0 < rn n := (Filter.eventually_gt_atTop (0 : ℕ)).mono fun n hn => inv_pos.mpr (Real.sqrt_pos.mpr (by exact_mod_cast hn)) 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|) hrn_pos (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| := Finset.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:411