Kernel ridge regression and GBLUP
TheoremPositive definiteness of the GBLUP matrix#✓fully proved
For λ > 0 the GBLUP matrix ZZᵀ + λI is positive definite.
theorem posDef_mul_transpose_add (Z : Matrix (Fin m) ι ℝ) {lam : ℝ} (hlam : 0 < lam) :
(Z * Zᵀ + lam • (1 : Matrix (Fin m) (Fin m) ℝ)).PosDef
Used by 2
TheoremPush-through identity for ridge regression#✓fully proved
The push-through identity (ZᵀZ + λI)⁻¹ Zᵀ = Zᵀ (ZZᵀ + λI)⁻¹ for λ > 0.
theorem transpose_mul_add_inv_mul_transpose (Z : Matrix (Fin m) ι ℝ) {lam : ℝ} (hlam : 0 < lam) :
(Zᵀ * Z + lam • (1 : Matrix ι ι ℝ))⁻¹ * Zᵀ =
Zᵀ * (Z * Zᵀ + lam • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹
Uses 2 · Used by 2
TheoremRR-BLUP = GBLUP#✓fully proved
RR-BLUP = GBLUP (fitted values): Z (ZᵀZ + λI)⁻¹ Zᵀ = ZZᵀ (ZZᵀ + λI)⁻¹ for λ > 0.
theorem mul_ridgeHat_eq_gblupHat (Z : Matrix (Fin m) ι ℝ) {lam : ℝ} (hlam : 0 < lam) :
Z * (Zᵀ * Z + lam • (1 : Matrix ι ι ℝ))⁻¹ * Zᵀ =
Z * Zᵀ * (Z * Zᵀ + lam • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹
Uses 1
TheoremRidge marker effects are back-solved from GBLUP#✓fully proved
The ridge marker effects are back-solved from GBLUP:
(ZᵀZ + λI)⁻¹ Zᵀ y = Zᵀ (ZZᵀ + λI)⁻¹ y.
theorem ridgeEstimate_eq (Z : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) {lam : ℝ} (hlam : 0 < lam) :
ridgeEstimate Z y lam =
Zᵀ *ᵥ ((Z * Zᵀ + lam • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹ *ᵥ y)
noncomputable def ridgeEstimate (X : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) (lam : ℝ) : ι → ℝ :=
(Xᵀ * X + lam • 1)⁻¹ *ᵥ (Xᵀ *ᵥ y)
CSLibExt/MachineLearning/Regression/LeastSquares.lean:279
Uses 2 · Used by 1
TheoremRR-BLUP = GBLUP#✓fully proved
RR-BLUP = GBLUP (predictions): for any genotypes Z' (training or new individuals),
Z' β̂ = Z' Zᵀ (ZZᵀ + λI)⁻¹ y.
theorem mulVec_ridgeEstimate {τ : Type*} (Z' : Matrix τ ι ℝ)
(Z : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) {lam : ℝ} (hlam : 0 < lam) :
Z' *ᵥ ridgeEstimate Z y lam =
(Z' * Zᵀ * (Z * Zᵀ + lam • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹) *ᵥ y
noncomputable def ridgeEstimate (X : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) (lam : ℝ) : ι → ℝ :=
(Xᵀ * X + lam • 1)⁻¹ *ᵥ (Xᵀ *ᵥ y)
CSLibExt/MachineLearning/Regression/LeastSquares.lean:279
Uses 2 · Used by 2
The Gaussian-process view
DefinitionLinear marker kernel on genotype vectors#✓fully proved
The linear marker kernel k(a, b) = s ⟪a, b⟫ = s ∑ⱼ aⱼ bⱼ on genotype vectors: the
covariance of genetic values aᵀβ and bᵀβ when the marker effects β are independent with
variance s.
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
TheoremFormula for the linear marker kernel#✓fully proved
Unfolding markerKernel.
theorem markerKernel_apply (s : ℝ) (a b : ι → ℝ) : markerKernel s a b = s * (a ⬝ᵥ b)
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
CSLibExt/MachineLearning/Regression/GBLUP.lean:129
Uses 1
TheoremKernel matrix of the marker kernel#✓fully proved
The kernel matrix of the marker kernel between genotypes Z' and Z is s Z' Zᵀ.
theorem kernelMatrix_markerKernel {τ ν : Type*} (s : ℝ) (Z' : Matrix τ ι ℝ) (Z : Matrix ν ι ℝ) :
kernelMatrix (markerKernel s) Z' Z = s • (Z' * Zᵀ)
def kernelMatrix (k : X → X → ℝ) {α β : Type*} (a : α → X) (b : β → X) : Matrix α β ℝ :=
Matrix.of fun i j => k (a i) (b j)
CSLibExt/MachineLearning/GaussianProcessRegression.lean:50
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
CSLibExt/MachineLearning/Regression/GBLUP.lean:129
Uses 2 · Used by 3
TheoremPositive semidefiniteness of the marker kernel matrix#✓fully proved
For s ≥ 0 the marker kernel is a covariance kernel: its kernel matrix on any inputs is
positive semidefinite.
theorem kernelMatrix_markerKernel_posSemidef {ν : Type*} [Finite ν] {s : ℝ} (hs : 0 ≤ s)
(Z : Matrix ν ι ℝ) : (kernelMatrix (markerKernel s) Z Z).PosSemidef
def kernelMatrix (k : X → X → ℝ) {α β : Type*} (a : α → X) (b : β → X) : Matrix α β ℝ :=
Matrix.of fun i j => k (a i) (b j)
CSLibExt/MachineLearning/GaussianProcessRegression.lean:50
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
CSLibExt/MachineLearning/Regression/GBLUP.lean:129
Uses 3 · Used by 1
TheoremGP posterior mean = GBLUP#✓fully proved
For the marker kernel with variance s > 0 and noise variance
σ² > 0, the predictive-mean matrix K(Z', Z) (K(Z, Z) + σ² I)⁻¹ of Gaussian-process
regression is Z' Zᵀ (ZZᵀ + (σ²/s) I)⁻¹.
theorem gpMean_markerKernel {τ : Type*} {s σ2 : ℝ} (hs : 0 < s) (hσ : 0 < σ2)
(Z' : Matrix τ ι ℝ) (Z : Matrix (Fin m) ι ℝ) :
kernelMatrix (markerKernel s) Z' Z *
(kernelMatrix (markerKernel s) Z Z + σ2 • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹ =
Z' * Zᵀ * (Z * Zᵀ + (σ2 / s) • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹
def kernelMatrix (k : X → X → ℝ) {α β : Type*} (a : α → X) (b : β → X) : Matrix α β ℝ :=
Matrix.of fun i j => k (a i) (b j)
CSLibExt/MachineLearning/GaussianProcessRegression.lean:50
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
CSLibExt/MachineLearning/Regression/GBLUP.lean:129
Uses 4 · Used by 2
TheoremGP posterior mean = RR-BLUP#✓fully proved
With the marker kernel, the GP predictive mean at genotypes
Z' is Z' β̂ for the ridge marker effects β̂ with λ = σ²/s.
theorem gpMean_markerKernel_mulVec {τ : Type*} {s σ2 : ℝ} (hs : 0 < s)
(hσ : 0 < σ2) (Z' : Matrix τ ι ℝ) (Z : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) :
(kernelMatrix (markerKernel s) Z' Z *
(kernelMatrix (markerKernel s) Z Z + σ2 • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹) *ᵥ y =
Z' *ᵥ ridgeEstimate Z y (σ2 / s)
def kernelMatrix (k : X → X → ℝ) {α β : Type*} (a : α → X) (b : β → X) : Matrix α β ℝ :=
Matrix.of fun i j => k (a i) (b j)
CSLibExt/MachineLearning/GaussianProcessRegression.lean:50
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
CSLibExt/MachineLearning/Regression/GBLUP.lean:129
noncomputable def ridgeEstimate (X : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) (lam : ℝ) : ι → ℝ :=
(Xᵀ * X + lam • 1)⁻¹ *ᵥ (Xᵀ *ᵥ y)
CSLibExt/MachineLearning/Regression/LeastSquares.lean:279
Uses 5
TheoremThe GBLUP posterior#✓fully proved
If the genetic values Z' β of individuals with genotypes Z' and
the phenotypes y = Z β + ε of the training individuals are jointly Gaussian with the covariance
of the marker kernel (marker-effect variance s > 0, residual variance σ² > 0), then given y
the genetic values are Gaussian with mean Z' Zᵀ (ZZᵀ + (σ²/s) I)⁻¹ y, which is the RR-BLUP
prediction Z' β̂ (gpMean_markerKernel_mulVec), and covariance
s (Z' Z'ᵀ - Z' Zᵀ (ZZᵀ + (σ²/s) I)⁻¹ Z Z'ᵀ).
theorem condDistrib_markerKernel {s σ2 : ℝ} (hs : 0 < s) (hσ : 0 < σ2) (Z' : Matrix τ ι ℝ)
(Z : Matrix (Fin m) ι ℝ) {V : Ω → EuclideanSpace ℝ (τ ⊕ Fin m)} (hV : Measurable V)
(hlaw : P.map V = multivariateGaussian 0 (jointCov (markerKernel s) σ2 Z' Z)) :
∀ᵐ y ∂P.map (fun ω => toEuclideanLin (targetPart (τ := τ)) (V ω)),
condDistrib (fun ω => toEuclideanLin (testPart (ν := Fin m)) (V ω))
(fun ω => toEuclideanLin (targetPart (τ := τ)) (V ω)) P y =
multivariateGaussian
(toEuclideanLin (Z' * Zᵀ * (Z * Zᵀ + (σ2 / s) • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹) y)
(s • (Z' * Z'ᵀ - Z' * Zᵀ * (Z * Zᵀ + (σ2 / s) • (1 : Matrix (Fin m) (Fin m) ℝ))⁻¹ *
(Z * Z'ᵀ)))
def jointCov (k : X → X → ℝ) (σ2 : ℝ) (xt : τ → X) (xs : ν → X) :
Matrix (τ ⊕ ν) (τ ⊕ ν) ℝ :=
fromBlocks (kernelMatrix k xt xt) (kernelMatrix k xt xs) (kernelMatrix k xs xt)
(kernelMatrix k xs xs + σ2 • 1)
CSLibExt/MachineLearning/GaussianProcessRegression.lean:55
noncomputable def markerKernel (s : ℝ) (a b : ι → ℝ) : ℝ :=
s * (a ⬝ᵥ b)
CSLibExt/MachineLearning/Regression/GBLUP.lean:129
noncomputable def targetPart : Matrix ν (τ ⊕ ν) ℝ := blockRow 0 1
CSLibExt/MachineLearning/GaussianProcessRegression.lean:64
noncomputable def testPart : Matrix τ (τ ⊕ ν) ℝ := blockRow 1 0
CSLibExt/MachineLearning/GaussianProcessRegression.lean:61
The RKHS view
TheoremKernel ridge regression = GBLUP = RR-BLUP#✓fully proved
In a real RKHS whose kernel has Gram matrix
ZZᵀ at the training inputs, the kernel ridge fit (the minimizer of
∑ᵢ (yᵢ - f xᵢ)² + λ ‖f‖², kernelRidgeRisk_kernelRidgeFit_le) has fitted values Z β̂.
theorem kernelRidgeFit_eq_mulVec_ridgeEstimate {X H : Type*} [NormedAddCommGroup H]
[InnerProductSpace ℝ H] [CompleteSpace H] [RKHS ℝ H X ℝ] (x : Fin m → X)
(Z : Matrix (Fin m) ι ℝ) (hK : kernelGram H x = Z * Zᵀ) (y : Fin m → ℝ) {lam : ℝ}
(hlam : 0 < lam) (j : Fin m) :
kernelRidgeFit H x y lam (x j) = (Z *ᵥ ridgeEstimate Z y lam) j
noncomputable def kernelGram (x : Fin n → X) : Matrix (Fin n) (Fin n) ℝ :=
Matrix.of fun i j => kernel H (x i) (x j) 1
MathlibExt/Analysis/FunctionalAnalysis/RepresenterTheorem.lean:288
noncomputable def kernelRidgeFit (x : Fin n → X) (y : Fin n → ℝ) (lam : ℝ) : H :=
kernelExpansion H x ((kernelGram H x + lam • (1 : Matrix (Fin n) (Fin n) ℝ))⁻¹ *ᵥ y)
MathlibExt/Analysis/FunctionalAnalysis/RepresenterTheorem.lean:296
noncomputable def ridgeEstimate (X : Matrix (Fin m) ι ℝ) (y : Fin m → ℝ) (lam : ℝ) : ι → ℝ :=
(Xᵀ * X + lam • 1)⁻¹ *ᵥ (Xᵀ *ᵥ y)
CSLibExt/MachineLearning/Regression/LeastSquares.lean:279
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.