Machine Learning in Data Processing
Machine Learning in Data Processing
Xiang-Sheng Wang
Chisheng Wang
Machine
Learning
in Data
Processing
Forum for Interdisciplinary Mathematics
Editor-in-Chief
Viswanath Ramakrishna, University of Texas, Richardson, USA
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland
AG 2026
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether
the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse
of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and
transmission or information storage and retrieval, electronic adaptation, computer software, or by similar
or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book
are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or
the editors give a warranty, expressed or implied, with respect to the material contained herein or for any
errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
vii
viii Preface
This book is intended for two primary audiences: students majoring in math-
ematics or statistics who are not actively working in machine learning but wish
to understand its fundamental concepts and terminology, and students from other
disciplines who have practical experience using machine learning tools and seek
a rigorous understanding of the mathematical foundations underlying these tech-
niques.
A central objective of this book is to promote machine learning as a standard
undergraduate or graduate course—comparable to differential equations—requiring
minimal prerequisites in programming and statistics. By relying primarily on cal-
culus and linear algebra, the material is accessible to students who have completed
basic coursework in these subjects.
To achieve this accessibility, the presentation is deliberately elementary and self-
contained. Upon completing this book or a course based on it, students should
acquire foundational knowledge of linear and nonlinear regression, regularization,
neural networks, batch normalization, support vector machines, gradient-based
optimization methods, and principal component analysis. The exposition follows
a theorem-and-proof style to ensure mathematical rigor and clarity.
Python is chosen as the programming language because it is free, widely
available, and easy to read. Although programming languages evolve over time,
Python’s simplicity makes it particularly suitable for beginners. Code examples are
intentionally kept short—typically no more than 30–40 lines—and avoid reliance
on specialized libraries.
The first author gratefully acknowledges the unwavering support of his wife,
Hongying, and his children, Mingqian and Tongwei. The second author gratefully
acknowledges the constant encouragement of his wife, Yanhong, and his children,
Yuchen and Xihe. The authors are deeply thankful for their families’ support, which
enabled them to persevere through the challenges of completing this book.
1 Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Notations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Determinant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Block Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Rank. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.5 Fréchet Derivative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1 Notations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2 Linear Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3 Maximum Likelihood Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.4 Least Squares Approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Sum of Squared Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6 Variance Inflation Factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.7 Python Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3 Regularization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.1 Overfitting Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2 Ridge Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.3 Convex Optimization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.4 LASSO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5 Python Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6 Discussions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4 Nonlinear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.1 Nonlinear Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2 Sigmoid Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.3 Optimization Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.4 Gradient Descent Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
xi
xii Contents
1.1 Notations
Explicitly,
(i,j )
Akl
. = Ak l , 1 ≤ k ≤ n − 1, 1 ≤ l ≤ m − 1,
where
k, k < i, l, l < j,
k =
. l =
k + 1, k ≥ i, l + 1, l ≥ j.
ATjk = Akj , 1 ≤ j ≤ m, 1 ≤ k ≤ n.
.
The product of two matrices A ∈ Rn×m . and B ∈ Rm×p . is the matrix AB ∈ Rn×p .
given by
m
(AB)ij =
. Aik Bkj , 1 ≤ i ≤ n, 1 ≤ j ≤ p.
k=1
1, j = k,
δj k =
.
0, j k.
AB = BA = I.
.
s(i1 , · · · , ij , · · · , ik , · · · , in ) = −s(i1 , · · · , ik , · · · , ij , · · · , in ).
.
1.2 Determinant 3
1.2 Determinant
Given a function f on Rn×n ., we say that f is multilinear if, for any k = 1, · · · , n.,
any scalars α, β ∈ R., and any vectors A1 , · · · , An , B1 , · · · , Bn ∈ Rn .,
f (A1 , · · · , Aj , · · · , Ak , · · · , An ) = −f (A1 , · · · , Ak , · · · , Aj , · · · , An ),
.
(1.2)
that is, f changes sign whenever two of its vector arguments are interchanged. We
say that f is normalized if
f (I ) = f (e1 , · · · , en ) = 1,
. (1.3)
A, A ∈ R,
f (A) =
.
n
(1.4)
i=1 (−1)
i−1 A f (A(i,1) ),
i1 A ∈ Rn×n , n > 1.
n
= (−1)i−1 Ai1 f (A(i) (i) (i) (i) (i)
2 , · · · , Ak−1 , αAk + βBk , Ak+1 , · · · , An ),
(i)
i=1
where A(i)j ∈ R
n−1 . (respectively, B (i) ∈ Rn−1 .) denotes the vector obtained from
j
Aj . (respectively, Bj .) by deleting its i-th component. Since f is multilinear on
R(n−1)×(n−1) ., we have
n
=α (−1)i−1 Ai1 f (A(i) (i) (i) (i)
2 , · · · , Ak−1 , Ak , Ak+1 , · · · , An )
(i)
i=1
n
(i) (i) (i) (i)
+β (−1)i−1 Ai1 f (A2 , · · · , Ak−1 , Bk , Ak+1 , · · · , A(i)
n )
i=1
Next, we obtain
f (αA1 + βB1 , A2 , · · · , An )
.
n
(i)
= (−1)i−1 (αAi1 + βBi1 )f (A2 , · · · , A(i)
n )
i=1
f (A1 , · · · , Aj , · · · , Ak , · · · , An ) = 0.
.
1.2 Determinant 5
where Pn . denotes the set of all permutations of the indices (1, 2, · · · , n)..
Proof By the multilinearity of f , we obtain
n
f (A1 , · · · , An ) =
. f (ei1 , · · · , ein ) Aij j .
(i1 ,··· ,in )∈Pn j =1
where s(i1 , · · · , in ). denotes the sign of the permutation (i1 , · · · , in ).. This completes
the proof.
According to Lemma (1.1) and Lemma (1.2), the determinant function is
uniquely determined by the conditions of normalization, antisymmetry, and mul-
tilinearity. From now on, we shall use det. to denote the determinant function. The
following properties are easy to verify.
Proposition 1.1 Given A = (A1 , · · · , An ) ∈ Rn×n ., we have
n
det(A), i = j,
. (−1)i+k Aki det(A(k,j ) ) = det(A)δij = (1.7)
k=1 0, i j.
In particular, if A is invertible, then det(A) 0.. On the other hand, if det(A) 0.,
then A is invertible with
(−1)i+j det(A(j,i) )
(A−1 )ij =
. . (1.11)
det(A)
A B
M=
. ∈ R(m+p)×(n+q)
C D
such that
⎧
⎪
⎪Aij , i = 1, · · · , m, j = 1, · · · , n,
⎪
⎪
⎨B i = 1, · · · , m, j = n + 1, · · · , n + q,
i,j −n ,
.Mij =
⎪
⎪ Ci−m,j , i = m + 1, · · · , m + p, j = 1, · · · , n,
⎪
⎪
⎩
Di−m,j −n , i = m + 1, · · · , m + p, j = n + 1, · · · , n + q.
A B Ã B̃ AÃ + B C̃ AB̃ + B D̃
. = . (1.12)
C D C̃ D̃ C Ã + D C̃ C B̃ + C D̃
1.3 Block Matrix 7
Proof Let
A B Ã B̃
M=
. ∈ R(m+p)×(n+q) , M̃ = ∈ R(n+q)×(r+s) .
C D C̃ D̃
Then
n+q
(M M̃)ij =
. Mik M̃kj , i = 1, · · · , m + p, j = 1, · · · , r + s.
k=1
n n+q
(M M̃)ij =
. Aik Ãkj + Bi,k−n C̃k−n,j = (AÃ + B C̃)ij .
k=1 k=n+1
n n+q
(M M̃)ij =
. Ci−m,k Ãkj + Di−m,k−n C̃k−n,j = (C Ã + D C̃)i−m,j .
k=1 k=n+1
n n+q
(M M̃)ij =
. Ci−m,k B̃k,j −r + Di−m,k−n D̃k−n,j −r = (C B̃ + D D̃)i−m,j −r .
k=1 k=n+1
A B
M=
. ∈ R(m+n)×(m+n) ,
C D
A 0
. det(M) = det = det(A) det(D). (1.13)
C D
A(1,j ) 0
M (1,j ) =
. ,
C (0,j ) D
where A(1,j ) ∈ R(m−1)×(m−1) . is obtained from A by removing its first row and j -th
column, and C (0,j ) ∈ Rn×(m−1) . is obtained from C by removing its j -th column.
By the induction hypothesis,
= det(A) det(D),
A B
M=
. ∈ R2n×2n ,
C D
A B
. det(M) = det = det(AD − CB). (1.14)
C D
Proof We first consider the case where A is invertible; that is, det(A) 0.. Observe
that
I 0 A B A B
. = .
−CA−1 I C D 0 D − CA−1 B
1.4 Rank 9
Taking determinants on both sides and applying Proposition 1.1 and Lemma 1.4
give
A B
. det = det(A) det(D − CA−1 B) = det(AD − ACA−1 B).
C D
.p(λ) = det(A + λI ) = λn + · · · , λ ∈ R.
By the fundamental theorem of algebra, p(λ). has at most n real roots. Hence,
there exists ε0 > 0. such that p(ε) 0. for all ε ∈ (0, ε0 ).. For each such ε., set
Aε = A + εI ., which is invertible. By the previous argument, we have
Aε B
. det = det(Aε D − CB).
C D
1.4 Rank
We say that the rank of a matrix A ∈ Rm×n . is r if there exist invertible matrices
P ∈ Rm×m . and Q ∈ Rn×n . such that
P AQ = (e1 , · · · , er , 0, · · · , 0) ∈ Rm×n ,
.
Pij , j = 1, · · · , r,
Aij =
.
0, j = r + 1, · · · , n.
Qij , i = 1, · · · , s,
. Aij =
0, i = s + 1, · · · , m.
Pij =0, i = s + 1, · · · , m, j = 1, · · · , r,
.
Qij =0, i = 1, · · · , s, j = r + 1, · · · , n.
B 0
Q=
. ,
C D
E 0
.PT = ,
F G
Q 0
(M, 0) = P (e1 , · · · , er , 0, · · · , 0)
. ,
0 I
and hence
. rank(M, 0) = rank(M).
Furthermore
(A1 , · · · , Ak )v = A1 v1 + · · · + Ak vk = 0.
.
(A1 , · · · , Ak )v = 0
.
which implies
|f (x + h) − f (x) − Lh|
. lim = 0.
h→0 h
|F (x + h) − F (x) − Ah|
. lim = 0.
h→0 h
⎛ ⎞
∂F1 ∂Fm
∂x1 (x) ··· ∂x1 (x)
⎜ ⎟
F (x) = ⎜
.
⎝
..
.
..
.
⎟ ∈ Rn×m .
⎠ (1.17)
∂F1 ∂Fm
∂xn (x) · · · ∂xn (x)
The following identities extend the product rule and chain rule for Fréchet
derivatives.
Proposition 1.5 Let A ∈ Rn×n ., and define f (x) = x T Ax . for x ∈ Rn .. Then
f (x) = (A + AT )x ∈ Rn , f (x) = A + AT .
. (1.19)
Let F, G ∈ C 1 (Rn , Rm )., and define f (x) = F (x)T G(x). for x ∈ Rn .. Then
and
1
g(1) = g(0) + g (0) + g (ξ ).
.
2
Problems
1.1 For any A ∈ Rn×m . and B ∈ Rm×p ., prove that (AB)T = B T AT ..
1.2 If A, B ∈ Rn×n . are invertible, prove that AB is also invertible with (AB)−1 =
B −1 A−1 ..
1.3 Define f (A) = A11 A22 − A21 A12 . for A ∈ R2×2 .. Verify that f is a normalized,
antisymmetric, and multilinear function on R2×2 ..
1.4 Show that a multilinear function f on Rn×n . is antisymmetric if and only if
f (A1 , · · · , An ) = 0
.
2.1 Notations
Throughout this chapter, we use d to denote the dimension (i.e., number of features)
of the input data. The data size is n. The output data is a column vector
⎛ ⎞
y1
⎜y2 ⎟
⎜ ⎟
.y = ⎜ . ⎟ ∈ R .
n
(2.1)
⎝ .. ⎠
yn
To account for the constant term in the linear regression model, we introduce an
additional column of ones and denote the augmented input data as
⎛ ⎞
x10 x11 · · · x1d
⎜x20 x21 · · · x2d ⎟
⎜ ⎟
.x = ⎜ . .. ⎟ ∈ R
n×(d+1)
.. , (2.2)
⎝ .. . . ⎠
xn0 xn1 · · · xnd
where xi0 = 1. for i = 1, · · · , n.. For each j = 0, · · · , d ., we denote the j -th column
of x by
⎛ ⎞
x1j
⎜x2j ⎟
⎜ ⎟
.xj = ⎜ . ⎟ ∈ R .
n
(2.3)
⎝ .. ⎠
xnj
In particular,
⎛ ⎞
1
⎜1⎟
⎜ ⎟
.x0 = ⎜ . ⎟ ∈ R
n
(2.4)
⎝ .. ⎠
1
is the column vector added to the input data to represent the constant term in the
linear regression model. The other column vectors x1 , · · · , xd ∈ Rn . are also called
the features of the input data, while the output vector y ∈ Rn . is referred to as the
observation.
The main problem in linear regression model is stated as follows, with illustration
given in Fig. 2.1.
Objective
Given features x1 , · · · , xd ∈ Rn . and observations y ∈ Rn ., we need to find a
parameter vector
⎛ ⎞
p0
⎜ p1 ⎟
⎜ ⎟
.p = ⎜ . ⎟ ∈ R
d+1
(2.5)
⎝ .. ⎠
pd
Y := xp = x0 p0 + x1 p1 + · · · + xd pd
. (2.6)
ε := y − Y ∈ Rn
. (2.7)
denotes the i-th component of the error vector (with i = 1, · · · , n.), then ε1 , · · · , εn .
are independent and identically distributed (i.i.d.) random variables satisfying a
normal distribution with mean 0 and variance σ 2 ..
For a given observation vector y ∈ Rn ., the likelihood function is
⎧ ⎛ ⎞2 ⎫
⎪
⎨ 1 n d ⎪
⎬
1 ⎝yi − ⎠
L(p, σ 2 |y) =
. exp − 2 xij pj . (2.9)
(2π σ 2 )n/2 ⎪
⎩ 2σ ⎪
⎭
i=1 j =0
We then define a good approximation as the one that maximizes the above
likelihood function. The problem of finding the maximum likelihood estimation
of the parameter vector p is equivalent to the problem of minimizing the sum of
squared errors (SSE) defined as below:
20 2 Linear Regression
⎛ ⎞2
n d
SSE :=
. ⎝yi − xij pj ⎠ y−Y 2
2, (2.10)
i=1 j =0
Another interpretation of the good approximation is the one that minimizes the l 2 .-
norm of the error vector y − Y ..
Optimization Problem
Let x ∈ Rn×(d+1) . and y ∈ Rn . be given. Find p ∈ Rd+1 . such that the objective
function
⎛ ⎞2
n d
1 1 ⎝yi −
.J (p) := y − xp 2
2 = xij pj ⎠ (2.11)
2 2
i=1 j =0
is minimized.
The additional factor 1/2. in the objective function does not affect the solution
of the optimization problem and is included only for the sake of convenience.
The solution of the above optimization problem is also called the least squares
approximation. Since the objective function J (p). in (2.11) and the sum of squared
errors (SSE) in (2.10) differ by a constant factor, the least squares approximation is
equivalent to the maximum likelihood approximation.
Theorem 2.1 If det(x T x) 0., then the objective function J (p). in (2.11) has a
unique global minimum at
p = (x T x)−1 (x T y);
. (2.12)
for t ∈ R.. Obviously, f (0) = J (p). and f (1) = J (q).. By Taylor expansion, we
obtain
1
f (1) = f (0) + f (0) + f (s),
.
2
for some s ∈ (0, 1).. Note that
and
We obtain
1 1
J (q) − J (p) = f (1) − f (0) =
. f (s) = x(q − p) 2
2 ≥ 0.
2 2
Since q − p 0. and det(x T x) 0., we have J (q) > J (p).. Otherwise, x(q −
p) = 0. and x T x(q−p) = 0.; namely, 0 is an eigenvalue of x T x . with a corresponding
eigenvector q − p ., which is a contradiction to the assumption det(x T x) 0.. This
completes the proof.
In this section, we assume det(x T x) 0., and let p be the optimal solution as given
in (2.12). The following proposition shows that the prediction vector Y = xp. is the
projection of the observation vector y on the linear subspace spanned by the vectors
x0 , · · · , xd .; see Fig. 2.2.
Proposition 2.1 Given x ∈ Rn×(d+1) . and y ∈ Rn . with det(x T x) 0., let Y = xp .
with p = (x T x)−1 (x T y).. We have the following extension of Pythagorean theorem
. y−Y 2
2 y 2
2 Y 2
2. (2.13)
Y T (y − Y ) = pT x T y − p T x T xp = pT (x T y − x T xp) = 0.
.
. y−Y 2
2 = yT y − Y T y − yT Y + Y T Y = yT y − Y T Y y 2
2 Y 2
2.
22 2 Linear Regression
xT x xT y
B := (x, y)T (x, y) =
. ∈ R(d+2)×(d+2) . (2.14)
yT x yT y
The following proposition shows that the last diagonal term (i.e., the (d +2, d +2).
entry) of B −1 . is the reciprocal of the SSE.
Proposition 2.2 Given x ∈ Rn×(d+1) . and y ∈ Rn . with det(x T x) 0., let Y = xp .
with p = (x T x)−1 (x T y).. We have
−1
xT x xT y (x T x)−1 + pλpT − pλ
. = , (2.15)
yT x yT y −λpT λ
where
1 1
λ=
. = .
SSE y−Y 2
2
xT x xT y xT x 0 I p
. = .
yT x yT y 0 1 yT x yT y
Assume
I p A α I 0
. = .
yT x yT y βT λ 0 1
2.6 Variance Inflation Factor 23
We then have
A + pβ T = I, y T xA + y T yβ T = 0,
.
α + pλ = 0, y T xα + y T yλ = 1.
1 1 1
α = −pλ, λ =
. = T = ,
yT y − y xp
T y (y − Y ) SSE
and
.β T = −λy T x, A = I + pλy T x.
Finally,
−1
xT x xT y I + pλy T x − pλ (x T x)−1 0
. =
yT x yT y −λy T x λ 0 1
(x T x)−1 + pλpT − pλ
= .
−λpT λ
where
n
1
ȳ :=
. yi (2.17)
n
i=1
is the mean/average of the output data. Assume the input data x ∈ Rn×(d+1) . satisfies
the condition det(x T x) 0.. Assume further that the sample variance of the output
24 2 Linear Regression
J (p)
R2 = 1 −
. .
J (q)
By Theorem 2.1, we obtain J (p) ≤ J (q)., and hence R 2 ≥ 0.. This completes the
proof.
Recall that x = (x0 , x1 , · · · , xd ) ∈ Rn×(d+1) . with x0 = (1, 1, · · · , 1)T ∈
Rn .. If R 2 = 1., then the observation vector y can be expressed as a linear
combination of x0 , · · · , xd ., and the matrix B = (x, y)T (x, y). becomes singular.
For each k = 1, · · · , d ., we consider the linear regression model with x (k) :=
(x0 , · · · , xk−1 , xk+1 , · · · , xd ) ∈ Rn×d . as the input data and xk . as the output data;
that is, we find the parameter vector p (k) ∈ Rd . such that the prediction vector
Xk = x (k) p(k) ∈ Rn . has the smallest Euclidean distance from xk ∈ Rn .. The
corresponding sum of squared errors is denoted as
n
SSEk
. xk − Xk 2
2 = (xik − Xik )2 . (2.19)
i=1
where
n
1
x̄k :=
. xik (2.21)
n
i=1
n
i=1 (xik − Xik )
SSEk 2
Rk2 := 1 −
. =1− n . (2.22)
nσk2 i=1 (xik − x̄k )
2
The following theorem indicates that a large VIF implies a strong linear
correlation between the features.
Theorem 2.3 Given the input data x = (x0 , x1 , · · · , xd ) ∈ Rn×(d+1) . with x0 =
(1, 1, · · · , 1)T ∈ Rn ., let V I F1 , · · · , V I Fd . be the variance inflation factors defined
as in (2.23). We obtain det(x T x) = 0. if and only if V I Fk = ∞. for some k ∈
{1, · · · , d}..
Proof Note that det(x T x) = 0. if and only if there exists k ∈ {1, · · · , d}. such that
xk . is linearly dependent of x0 , · · · , xk−1 , xk+1 , · · · , xd ., which is also equivalent to
SSEk = 0., where SSEk . is the sum of squared errors defined in (2.19). On account
of (2.23), we have SSEk = 0. if and only if V I Fk = ∞.. This completes the proof.
In this section, we provide a Python code to find the least squares solution,
coefficient of determination, and variance inflation factors of the linear regression
model.
26 2 Linear Regression
def linear_regression(x,y):
n=[Link][0]
p=[Link]([Link]([Link](x.T,x)),[Link](x.T,y))
SSE=[Link]([Link](x,p))**2
R2=1-SSE/(n*[Link](y))
Lambda=[Link]([Link]([Link](x.T,x)))
VIF=[Link](Lambda,n*[Link](x,axis=0))[1:]
result={
’p’:p,
’R2’:R2,
’VIF’:VIF
}
return result
n=1000
d=4
x0=[Link]((n,1))
x=[Link]((x0,[Link]((n,d))),axis=1)
p_exact=[Link]((d+1,1))
y=[Link](x,p_exact)+[Link](0,0.1,(n,1))
result=linear_regression(x,y)
p=result[’p’]
R2=result[’R2’]
VIF=result[’VIF’]
print(R2)
print(VIF)
print([Link]((p,p_exact),axis=1))
In the code, we choose the sample size n = 1000. and the dimension d = 4.. The
input data x1 , · · · , xd ∈ Rn . is randomly generated from the uniform distribution.
The exact parameter vector is set to be (1, · · · , 1)T ∈ Rd+1 .. The output data is
perturbed by normal random variables. A sample result is given below:
2.7 Python Code 27
Sample Result
0.9702959227690222
[1.00333685 1.005423 1.00388619 1.00681191]
[[0.99675087 1. ]
[1.00069386 1. ]
[0.98648815 1. ]
[1.00547332 1. ]
[1.01346316 1. ]]
Problems
2.1 For any x ∈ Rn×(d+1) ., show that x T x . is a symmetric and positive semidefinite
matrix in R(d+1)×(d+1) .. If x T x . is invertible, then it is positive definite.
2.2 Let x = (x0 , x1 , · · · , xd ) ∈ Rn×(d+1) ., where x0 , · · · , xd ∈ Rn . and x0 0..
Prove that det(x T x) = 0. if and only if there exists k ∈ {1, · · · , d}. such that xk . can
be represented as a linear combination of x0 , · · · , xk−1 , xk+1 , · · · , xd .; namely,
for
⎛ ⎞
p0
⎜ p1 ⎟
⎜ ⎟
.p = ⎜ . ⎟ ∈ R
d+1
.
⎝ .. ⎠
pd
for k = 0, · · · , d ..
(b) Verify that J (p) = x T x ∈ R(d+1)×(d+1) .; namely,
n
∂2
. J (p) = [J (p)]j k = (x T x)j k = xij xik ,
∂pj ∂pk
i=1
for j, k = 0, · · · , d ..
2.4 Given J ∈ C 2 (Rd+1 , R)., for any p ∈ Rd+1 . and q ∈ Rd+1 ., prove that there
exists ξ ∈ Rd+1 . such that
1
.J (q) = J (p) + (q − p)T J (p) + (q − p)T J (ξ )(q − p).
2
2.5 Prove that the variance inflation factor is no less than one; namely, V I Fk ≥ 1.,
where V I Fk . is defined in (2.23).
2.6 Given the input data x = (x0 , x1 , · · · , xd ) ∈ Rn×(d+1) . with x0 =
(1, 1, · · · , 1)T ∈ Rn ., let SSEk . with k = 1, · · · , d . be the sum of squared errors
defined as in (2.23). Assume det(x T x) 0., and let λ0 , · · · , λd . be the diagonal
terms of (x T x)−1 .. Show that λk = 1/SSEk . for k = 1, · · · , d ..
2.7 Use a linear regression model to solve the problem of fitting the points
(0, 0), (1, 2), (2, 1), (3, 3). by a straight line.
2.8 Given a positive integer n, calculate the mean and variance of the sequence
1, 2, · · · , n..
100
2.7 Python Code 29
calculate the variance inflation factors as defined in (2.23). Note that the sample size
is n = 3. and the dimension is d = 2..
2.10 Given an input matrix x ∈ Rn×(d+1) . such that det(x T x) 0., fix an
observation vector y ∈ Rn ., and find the parameter vector p ∈ Rd+1 . and the variance
σ 2 > 0. such that the likelihood function L(p, σ 2 |y). defined in (2.9) is maximized.
Chapter 3
Regularization
We continue with the linear regression code in Sect. 2.7. Now, we assume x2 . and x1 .
are closely related in the sense that the difference x2 − x1 . is sampled from a normal
distribution with mean 0 and a small variance. For simplicity, we do not repeat the
code for the linear regression function in Sect. 2.7.
Overfitting Example
import numpy as np
n=1000
d=4
x0=[Link]((n,1))
x=[Link]((x0,[Link]((n,d))),axis=1)
x[:,2]=x[:,1]+[Link](0,0.01,(n,))
p_exact=[Link]((d+1,1))
y=[Link](x,p_exact)+[Link](0,0.1,(n,1))
(continued)
result=linear_regression(x,y)
p=result[’p’]
R2=result[’R2’]
VIF=result[’VIF’]
print(R2)
print(VIF)
print([Link]((p,p_exact),axis=1))
Overfitting Result
0.9796829459418794
[803.11874709 802.97720154 1.01312437 1.01804729]
[[1.00094331 1. ]
[1.19645218 1. ]
[0.7916922 1. ]
[1.00670459 1. ]
[1.0056871 1. ]]
1 λ
J (p) =
. y − xp 2
2 + p 22 , (3.1)
2 2
where λ > 0. is a regularization constant to be tuned. It is also called a
hyperparameter or a tuning parameter.
Theorem 3.1 For any x ∈ Rn×(d+1) ., y ∈ Rn ., and λ > 0., the objective function
J (p). in (3.1) has a unique global minimum at
p = (x T x + λI )−1 (x T y);
. (3.2)
J (p) = x T (xp − y) + pλ = (x T x + λI )p − x T y = 0.
.
1 λ
J (q) − J (p) =
. (q − p)T (x T x + λI )(q − p) ≥ (q − p) 2
2 > 0.
2 2
This completes the proof.
We come back to the overfitting problem in Sect. 3.1. The Python code imple-
menting the ridge regression is given below:
Ridge Regression
import numpy as np
n=1000
d=4
x0=[Link]((n,1))
x=[Link]((x0,[Link]((n,d))),axis=1)
x[:,2]=x[:,1]+[Link](0,0.01,(n,))
p_exact=[Link]((d+1,1))
y=[Link](x,p_exact)+[Link](0,0.1,(n,1))
(continued)
34 3 Regularization
p=[Link]([Link]([Link](x.T,x)),[Link](x.T,y))
la=1
A=la*[Link](d+1)+[Link](x.T,x)
p_ridge=[Link]([Link](A),[Link](x.T,y))
print([Link]((p,p_exact,p_ridge),axis=1))
Sample Result
[[0.98693898 1. 0.99435015]
[1.15005244 1. 1.01000321]
[0.86133075 1. 0.99605137]
[1.00696983 1. 1.00073844]
[0.99278865 1. 0.98752897]]
It is noted that the result from the ridge regression (linear regression with l 2 .-
regularization) is closer to the exact parameter vector than that of linear regression.
This example illustrates that l 2 .-regularization helps reduce the side effect of
overfitting the data with correlated features.
for all u ∈ I ., v ∈ I ., and t ∈ [0, 1].. Note that a convex function is not necessarily
differentiable. For example, f (u) = |u|. is convex in R. but not differentiable at
u = 0.. The following lemma gives an alternative definition of a convex function;
see Fig. 3.1.
3.3 Convex Optimization 35
Lemma 3.1 Let I ⊂ R. be an open interval and f ∈ C(I, R).. Then f is convex in
I if and only if for any u ∈ I ., v ∈ I ., and w ∈ I . such that u < w < v ., we have
Proof First, we assume that (3.4) holds for all u ∈ I ., v ∈ I ., and w ∈ I . such that
u < w < v .. In particular, by choosing w = tu + (1 − t)v . with t ∈ (0, 1)., we obtain
from the first inequality in (3.4) that
f (u + h) − f (u)
f ± (u) := lim
.
h→0± h
36 3 Regularization
. lim g(h) ≥ 0,
h→0+
f + (u) ≥ 0 ≥ f − (v).
.
f (v) − f (u)
f + (u) ≤
. ≤ f − (v).
v−u
that f (w) = 0.. A simple integration from u to w then gives f (w) = f (u) = f (v).
for all w ∈ (u, v).. This proves (b).
Denote f (u) := λ|u|.. A simple calculation gives
⎧
⎪
⎪ u > 0,
⎨λ,
∂f (u) =
. −λ, u < 0, (3.6)
⎪
⎪
⎩[−λ, λ], u = 0.
1
J (u) =
. (u − z)2 + λ|u|, u ∈ R, (3.7)
2
where z ∈ R. and λ > 0. are given. Denote
⎧
⎪
⎨z − λ,
⎪ z > λ,
Fλ (z) :=
. z + λ, z < −λ, (3.8)
⎪
⎪
⎩0, z ∈ [−λ, λ].
3.4 LASSO
LASSO
Let x ∈ Rn×(d+1) . and y ∈ Rn . be given. Find p ∈ Rd+1 . such that the objective
function
⎛ ⎞2
n d d
1 1 ⎝yi −
J (p) :=
. y − xp 2
2 +λ p 1 = xij pj ⎠ + λ |pj |
2 2
i=1 j =0 j =0
(3.9)
is minimized.
for j = 0, · · · , d ..
Proof Define
1
g(p) :=
. y − xp 22 .
2
n d n
∂
. g(p) = (x T xp − x T y)j = xij xik pk − xij yi .
∂pj
i=1 k=0 i=1
Here, λ > 0. is the regularization parameter, and α > 0. is also called the learning
rate. Both hyperparameters are to be tuned in practical applications. In the special
case λ → 0+ ., the above iteration reduces to the steepest descent method:
Comparing with the direct formula in (2.12), the steepest descent method avoids
solving the inverse of the matrix x T x . which is generally dense and sometimes ill-
conditioned. The choice of the learning rate α > 0. depends on the specific problem.
In principle, a large α . may lead to divergence of the iteration, while a small α . may
induce some computation costs.
In this section, we provide a Python code to implement the iterative algorithm (3.11)
in LASSO.
LASSO Code
import numpy as np
def F(u,la):
return (u>la)*(u-la)+(u<-la)*(u+la)
def lasso(x,y,la,al,iter_max):
d=[Link][1]-1
p=[Link]((d+1,1))
for iter in range(iter_max):
u=p-al*[Link](x.T,[Link](x,p)-y)
p=F(u,la*al)
return p
n=1000
(continued)
40 3 Regularization
d=4
x0=[Link]((n,1))
x=[Link]((x0,[Link]((n,d))),axis=1)
p_exact=[Link]((d+1,1))
p_exact[3]=0
p_exact[4]=0
y=[Link](x,p_exact)+[Link](0,0.1,(n,1))
p=[Link]([Link]([Link](x.T,x)),[Link](x.T,y))
p_lasso=lasso(x,y,la=1,al=0.0001,iter_max=10000)
print([Link]((p,p_exact,p_lasso),axis=1))
In the code, we choose the sample size n = 1000. and the dimension d = 4.. The
input data x1 , · · · , xd ∈ Rn . is randomly generated from the uniform distribution.
The exact parameter vector is set to be pexact = (1, 1, 1, 0, 0)T ∈ R5 .. The output
data is perturbed by normal random variables. A sample result is given below:
Sample Result
[[ 1.01146268 1. 1.00860743]
[ 1.00235203 1. 0.99627135]
[ 0.99401163 1. 0.9872306 ]
[-0.0103034 0. 0. ]
[-0.00607228 0. 0. ]]
It is noted that the linear regression (without regularization) gives small but
nonzero estimations to p3 . and p4 .. However, by choosing a suitable regularization
parameter, the LASSO method estimates p3 = 0. and p4 = 0.. This example shows
that the LASSO method is able to select the significant features of the input data.
3.6 Discussions
1 1
J (p) =
. (p0 − 1)2 + (p1 − 0.01)2 ,
2 2
3.6 Discussions 41
1
p∗ =
. .
0.01
1 1 λ
Jˆ(p) = (p0 − 1)2 + (p1 − 0.01)2 + (p02 + p12 ),
.
2 2 2
and
1 1
J˜(p) = (p0 − 1)2 + (p1 − 0.01)2 + λ(|p0 | + |p1 |),
.
2 2
1 1
p̂ ∗ =
. ,
1 + λ 0.01
(1 − λ)+
p̃ ∗ =
. , (3.12)
(0.01 − λ)+
where the plus subscript denotes the maximum of the number and zero; namely,
x, x ≥ 0,
x+ := max{x, 0} =
. (3.13)
0, x ≤ 0.
Problems
3.1 For any x ∈ Rn×(d+1) . and y ∈ Rn ., show that the equation x T xp = x T y . has
infinitely many solutions if and only if det(x T x) = 0..
42 3 Regularization
and the output data y = (0, 2, 1, 3)T ., find the optimal parameter vector(s) p ∈ R3 .
such that the sum of squared errors SSE y − xp 22 . is minimized.
3.3 Given x ∈ Rn×(d+1) . and λ > 0., prove that the matrix x T x + λI . is positive
definite and hence invertible, where I is the identity matrix of dimension d + 1..
3.4 Given x ∈ Rn×(d+1) ., y ∈ Rn ., and λ > 0., define a function
⎛ ⎞2
n d d
1 λ 1 ⎝yi − 1
.J (p) = y − xp 2+
2
p 2
2 = xij pj ⎠ + pj2
2 2 2 2
i=1 j =0 j =0
for
⎛ ⎞
p0
⎜ ∂1 ⎟
⎜ ⎟
.p = ⎜ . ⎟ ∈ R
d+1
.
⎝ .. ⎠
∂d
for j, k = 0, · · · , d ., where
1 j = k,
δj k =
.
0 j k
3.5 In the Python code given in Section 3.2, tune the hyperparameter λ. from 10−3 .
to 103 ., and find the pattern of changes in the bias and variance of the solution.
3.6 Let f ∈ C 2 (I, R)., where I ⊂ R. is an open interval. Prove that f is convex in
I if and only if f (u) ≥ 0. for all u ∈ I ..
3.7 Let f ∈ C(I, R). be a convex function on an open interval I ⊂ R.. For any
u ∈ I ., prove that the one-sided derivatives
f (u + h) − f (u)
f ± (u) := lim
.
h→0± h
exist and f − (u) ≤ f + (u).. Moreover, the derivative f (u). exists if and only if
f − (u) = f + (u)..
3.8 Let f ∈ C 1 (I, R). be a convex function on an open interval I ⊂ R.. Then u ∈ I .
is a local minimum of f if and only if f (u) = 0.. Moreover, any local minimum of
f in I is global in I .
3.9 Let f ∈ C(I, R). be a convex function on an open interval I ⊂ R.. For any
u ∈ I . and v ∈ I . with u < v ., prove that f + (u) ≤ f − (v)..
3.10 Let f ∈ C(I, R). be a convex function on an open interval I ⊂ R.. Given
u ∈ I ., prove that c ∈ ∂f (u). if and only if f (v) − f (u) ≥ c(v − u). for any v ∈ I ..
3.11 Let f ∈ C(I, R). be a convex function on an open interval I ⊂ R.. Given
g ∈ C 1 (I, R)., prove that u ∈ I . is a local minimum of f + g . if and only if 0 ∈
∂f (u) + g (u). (i.e., f − (u) ≤ −g (u) ≤ f + (u).).
3.12 Verify (3.12).
Chapter 4
Nonlinear Regression
Abstract Linear regression is applicable only when the output depends approxi-
mately linearly on the input. In many real-world datasets, however, this relationship
is not necessarily linear, and a nonlinear regression model may provide a more
appropriate description. In this chapter, we use logic gates as illustrative examples to
demonstrate how nonlinear regression succeeds in situations where linear regression
fails. The nonlinear regression model differs from the linear regression model in two
major aspects: (i) The linear activation function is replaced by a sigmoid function (or
a hyperbolic tangent function), and (ii) a logarithmic loss function is used to measure
approximation errors instead of a quadratic loss. The resulting optimization problem
is not well-posed in the sense that a global minimum cannot be attained at any finite
parameter vector. Nevertheless, the gradient descent method can be employed as
an efficient numerical algorithm to obtain a good approximate solution. The logic
gate examples illustrate how machine learning can achieve accurate and efficient
predictions without explicitly solving the open problem of global optimization.
We use a simple example to illustrate how linear regression fails in fitting nonlinear
data. Consider a logic gate with two binary inputs x1 . and x2 . and one binary output
y. The dimension is d = 2., and the sample size is n = 4.. Table 4.1 illustrates the
input and output data of the AND gate.
For convenience, we use 1 and − 1. to denote True and False, respectively. The
input matrix of the AND gate can be written as
⎛ ⎞
1 1 1
⎜1 1 −1⎟
.x = ⎜ ⎟
⎝1 −1 1 ⎠ ∈ R .
4×3
(4.1)
1 −1 −1
0.5
−1.5
Since the linear regression model fails to give a satisfactory prediction, we need to
use a nonlinear regression model to fit the data.
1
S(t) :=
. , (4.3)
1 + e−t
which is increasing and bounded by its two horizontal asymptotes 0 and 1. However,
from mathematical point of view, any function obtained by scaling and shifting of
S(t). will have equivalent effects as S(t). in nonlinear regression and hence should
still be called the sigmoid function. In other words, for any real constants α1 ., β1 .,
α0 ., and β0 . such that α1 β1 = 0., the function
4.2 Sigmoid Function 47
β1
u(t) := β1 S(α1 t + α0 ) + β0 =
. + β0 (4.4)
1 + e−α1 t−α0
is also called a sigmoid function. The graph of u(t). is obtained from the graph of
S(t). by a sequence of three linear transformations: (i) shift to the left by α0 ., (ii) scale
by a diagonal matrix diag{1/α1 , β1 }., and (iii) shift up by β0 .. In this book, we shall
scale S(t). by a diagonal matrix diag{1/2, 2}. and then shift it down by 1; namely,
we choose α0 = 0., α1 = β1 = 2., and β0 = −1.. The resulting function is the same
as the hyperbolic tangent function:
2 1 − e−2t et − e−t
u(t) = 2S(2t) − 1 =
. − 1 = = = tanh t. (4.5)
1 + e−2t 1 + e−2t et + e−t
It is easily seen that u(t) = tanh t . is an odd and increasing function bounded by two
horizontal asymptotes ± 1.. We also note that
1
u (t) =
. = 1 − tanh2 t = 1 − [u(t)]2 . (4.6)
cosh2 t
The sigmoid function S(t). and its linear transformations are illustrated in Fig. 4.1.
2
S(t)
2S(2t)
1.5 tanh(t)
0.5
-0.5
-1
-5 0 5
Fig. 4.1 The sigmoid function S(t) = 1/(1 + e−t ). and its linear transformations
48 4 Nonlinear Regression
Y = tanh(xp),
. (4.7)
where, as usual, x ∈ Rn×(d+1) . is the input matrix, and p ∈ Rd+1 . is the model
parameter to be estimated. The above formula is interpreted as Yi = tanh((xp)i ). for
i = 1, · · · , n.. The output vector is binary: y ∈ {−1, 1}n ., which is different from
that in the linear regression model. Another difference between nonlinear and linear
regression model lies in the choice of objective function. In the linear regression
model, the Euclidean distance is used to measure the error between the prediction
vector and the observation vector. In the nonlinear regression model, we increase the
penalty when the prediction is closer to the opposite side of the observation. Given
a binary observation v ∈ {−1, 1}. and a prediction u ∈ (−1, 1)., we define the cost
function
2 ln 2 − (1 + v) ln(1 + u) − (1 − v) ln(1 − u)
C(u, v) :=
. . (4.8)
2
It is easily seen that
2 ln[2/(1 + u)], v = 1,
C(u, v) = ln
. = (4.10)
1 + uv ln[2/(1 − u)], v = −1.
Optimization Problem
Let x ∈ Rn×(d+1) . and y ∈ {−1, 1}n . be given. Find p ∈ Rd+1 . such that the
objective function
n
J (p) :=
. C(Yi , yi ) (4.11)
i=1
Let J (p). be the objective function given in (4.11). We will use the gradient descent
method to find a numerical approximation of the parameter vector p that minimizes
J (p).. For any i = 1, · · · , n., we obtain from
⎛ ⎞
d
Yi = tanh((xp)i ) = tanh ⎝
. xij pj ⎠
j =0
that
∂Yi
. = (1 − Yi2 )xij , j = 0, · · · , d.
∂pj
J (p) = x T (Y − y).
. (4.12)
for all α ∈ (0, α0 ).. It then follows from Taylor expansion that
α2
J (p − αJ (p)) − J (p) = −α J (p)
.
2
2 + [J (p)]T J (p − ξ J (p))J (p),
2
for some ξ ∈ (0, α).. Coupling the above two inequalities gives J (p − αJ (p)) <
J (p).. This completes the proof.
The gradient descent method is an iterative method to find the minimizer along the
direction of descent gradient; namely,
50 4 Nonlinear Regression
We use the nonlinear regression model to fit the AND gate. The gradient descent
method is implemented in the following Python code:
def nonlinear_regression(x,y,al,iter_max):
d=[Link][1]-1
p=[Link](0,1,(3,1))
for iter in range(iter_max):
p=p-al*[Link](x.T,[Link]([Link](x,p))-y)
return p
x=[Link]([[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1]])
y=[Link]([[1],[-1],[-1],[-1]])
p=nonlinear_regression(x,y,al=0.1,iter_max=1000)
print(p)
Y=[Link]([Link](x,p))
print([Link]((Y,y),axis=1))
Iteration Result
[[-2.99576037]
[ 2.99576042]
[ 2.99576041]]
[[ 0.99501275 1. ]
[-0.99501275 -1. ]
(continued)
4.6 Discussions 51
[-0.99501275 -1. ]
[-0.99999997 -1. ]]
It is noted that the nonlinear regression model fits the AND gate with a high
accuracy.
4.6 Discussions
We first discuss how the nonlinear regression model works for the AND gate. Note
from the result of numerical iteration via the gradient descent method in Sect. 4.5
that p = (−M, M, M)T ∈ R3 ., where M ≈ 3.. A simple calculation gives
⎛ ⎞ ⎛ ⎞
1 1 1 ⎛ ⎞ M
⎜1 1 −1⎟ −M ⎜ ⎟
.xp = ⎜ ⎟ ⎝ M ⎠ = ⎜ −M ⎟ .
⎝1 −1 1 ⎠ ⎝ −M ⎠
M
1 −1 −1 −3M
Note from Fig. 4.1 that the function tanh(t). has two horizontal asymptotes ± 1.;
namely, tanh(t) → ±1. as t → ±∞.. This implies that tanh(M) ≈ 1. for large
M > 0.. Actually, when M = 3., we have tanh(M) ≈ 0.995. and tanh(3M) ≈
0.99999997.. Hence, the prediction vector Y calculated in the above formula can be
regarded as a good approximation of the observation vector y = (1, −1, −1, −1)T ..
Finding the global minimum of a general objective function, with or without
constraints, remains an open problem in optimization. The effectiveness of machine
learning lies in the fact that an accurate approximation of the parameter vector need
not correspond to a global minimum, which in some cases may not even exist.
Instead, there often exist infinitely many parameter vectors that yield sufficiently
good approximations, and machine learning algorithms are able to identify such
solutions efficiently.
For example, in the nonlinear regression model of the AND gate, the parameter
vector p = (−M, M, M)T . is a good solution for any sufficiently large M > 0.. This
illustrates that, in practice, it is neither necessary nor typically possible to determine
the global minimum in a machine learning model. Rather, it suffices to perform
52 4 Nonlinear Regression
as M → ∞.. Thus,
4
. lim J (q(M)) = C(yi , yi ) = 0.
M→∞
i=1
Problems
4.1 Use a linear regression model to fit the OR gate. Find the parameter vector and
the prediction vector.
4.2 Verify that the function u(t) = (1 + e−2t )−1 . satisfies the differential equation
u (t) = u(t)[1 − u(t)]. with initial condition u(0) = 1/2..
4.6 Discussions 53
Table 4.2 The comparison between nonlinear regression and linear regression
Linear regression Nonlinear regression
Input matrix x ∈ Rn×(d+1) . x ∈ Rn×(d+1) .
Observation vector y ∈ Rn . y ∈ {−1, 1}n .
Model Y = xp ∈ Rn . Y = tanh(xp) ∈ (−1, 1)n .
Parameter vector p ∈ Rd+1 . p ∈ Rd+1 .
Cost function C(u, v) = (u − v)2 /2. C(u, v) = ln[2/(1 + uv)].
Objective function J (p) = ni=1 C(Yi , yi ). J (p) = ni=1 C(Yi , yi ).
Gradient J (p) = x T (Y − y). J (p) = x T (Y − y).
Gradient descent method p (k+1) = p(k) − αJ (p (k) ). p (k+1) = p(k) − αJ (p (k) ).
4.3 Verify that the function u(t) = (1 + e−2t )−1 . is the cumulative distribution
function of the logistic distribution with location parameter 0 and scale parameter
1/2.; namely,
t
u(t) =
. v(s)ds,
−∞
α2
J (q) − J (p) = −α J (p)
.
2
2 + [J (p)]T J (p − ξ J (p))J (p),
2
for some ξ ∈ (0, α)..
4.8 Use the nonlinear regression model to fit the OR gate; namely, find the
numerical approximation of p that minimizes the objective function J (p). in (4.11),
54 4 Nonlinear Regression
where the input matrix x is given as in (4.1), and the output vector is y =
(1, 1, 1, −1)T ∈ R4 ..
4.9 Consider the model Y = tanh(xp)., where x is given as in (4.1). Let M > 0. be a
sufficiently large constant. Determine which logic gate does the model approximate
when p is chosen as each of the following seven vectors:
⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞
M M M M −M −M −M
. ⎝M ⎠ , ⎝ M ⎠ , ⎝−M ⎠ , ⎝−M ⎠ , ⎝ M ⎠ , ⎝−M ⎠ , ⎝−M ⎠ .
M −M M −M −M M −M
4.10 Given J ∈ C 2 (Rd+1 , R). such that J (p). is positive definite for all p ∈ Rd+1 .,
prove that p ∈ Rd+1 . is a global minimum of J if and only if it is a critical point of
J ; namely, J (p) < J (q). for all q ∈ Rd+1 . if and only if J (p) = 0..
Chapter 5
Shallow Neural Network
5.1 Notations
1, x1 = x2 = 1,
x1 ∧ x2 = min{x1 , x2 } =
. (5.1)
−1, (x1 + 1)(x2 + 1) = 0.
1, (x1 − 1)(x2 − 1) = 0,
.x1 ∨ x2 = max{x1 , x2 } = (5.2)
−1, x1 = x2 = −1.
The XAND gate is the same as the product of x1 . and x2 ., which is denoted as
1, x1 = x2 ,
x1 · x2 =
. (5.3)
−1, x1 x2 .
The XOR gate is the negative of the XAND gate: − (x1 · x2 ).. One can easily verify
the following identities:
A logic gate has two binary inputs x1 . and x2 . and one binary output y. The
corresponding data has a dimension of d = 2. and a size of n = 4.. Table 5.1
illustrates the input and output data of the AND gate, OR gate, NAND gate, NOR
gate, and XOR gate, respectively.
The input matrix and the output vector of the XOR gate can be written as
⎛ ⎞
1 1 1
⎜1 1 −1⎟
.x = ⎜ ⎟
⎝1 −1 1 ⎠ ∈ R ,
4×3
(5.7)
1 −1 −1
and
⎛ ⎞
−1
⎜1⎟
.y = ⎜ ⎟
⎝ 1 ⎠∈R ,
4
(5.8)
−1
respectively. If we run the nonlinear regression code in Sect. 4.5 with the above x
and y, the simulation result is given below:
1 −1. −1
. 1 1 −1
. 1
−1. 1 −1
. 1 1 −1
. 1
−1. −1. −1
. −1
. 1 1 −1
.
5.3 Composite Function 57
Simulation Result
[[ 1.08017916e-17]
[ 7.93636823e-18]
[-2.85865445e-17]]
[[-9.84838471e-18 -1.00000000e+00]
[ 4.73247043e-17 1.00000000e+00]
[-2.57211212e-17 1.00000000e+00]
[ 3.14519678e-17 -1.00000000e+00]]
The parameter vector is close to (0, 0, 0)T ., and the prediction vector is also close
to the zero vector (0, 0, 0, 0)T ., which fails to approximate the observation vector of
XOR gate given in (5.8).
A careful examination of Table 5.1 shows that the XOR gate can be regarded as the
AND gate whose inputs are the outputs of the NAND gate and the OR gate; namely,
for any x1 ∈ B . and x2 ∈ B ., we have
Since each of the AND, NAND, and OR gates can be approximated by a nonlinear
sigmoid function with a linear combination, we approximate y as a composite
function of x1 . and x2 . in the sense that y is a function of two intermediate variables
z1 . and z2 . that approximates the AND gate, where z1 . and z2 . are functions of x1 . and
x2 . that approximate the NAND gate and the OR gate, respectively. This suggests us
to propose the following model. For each i = 1, 2, 3, 4., we define
Note that the composite function has a total of nine parameters: pj ., qj ., and rj . with
j = 0, 1, 2.. The objective function is given by
58 5 Shallow Neural Network
n
J (p, q, r) :=
. C(Yi , yi ), (5.13)
i=1
where C is the cost function defined in (4.8). We also recall from (4.9) that
∂C Yi − yi
. = .
∂Yi 1 − Yi2
n n
∂J ∂C ∂Yi
. = = (Yi − yi )zij , (5.14)
∂pj ∂Yi ∂pj
i=1 i=1
∂J ∂J ∂J T ∂J ∂J ∂J T ∂J ∂J ∂J T
Jp = (
. , , ) , Jq = ( , , ) , Jr = ( , , )
∂p0 ∂p1 ∂p2 ∂q0 ∂q1 ∂q2 ∂r0 ∂r1 ∂r2
and obtain
Jp =zT (Y − y), .
. (5.17)
Jq =x T [(Y − y) ∗ (1 − z1 ∗ z1 )]p1 , . (5.18)
Jr =x T [(Y − y) ∗ (1 − z2 ∗ z2 )]p2 , (5.19)
(5.20)
The Python code for the gradient descent method is given below:
XOR Code
import numpy as np
x=[Link]([[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1]])
y=[Link]([[-1],[1],[1],[-1]])
al=0.1
iter_max=1000
p=[Link](0,1,(3,1))
q=[Link](0,1,(3,1))
r=[Link](0,1,(3,1))
print([Link]((p,q,r),axis=1))
print([Link]((Y,y),axis=1))
5.5 Discussions
Simulation Result
[[-3.08739711 1.80172906 1.5999076 ]
[ 3.4102806 -1.95476405 1.77937427]
[ 3.42289907 -1.94572899 1.77547159]]
[[-0.99478607 -1. ]
[ 0.99725619 1. ]
[ 0.99726898 1. ]
[-0.99469775 -1. ]]
This example demonstrates that the optimization problem may lack a finite exact
solution and can have multiple approximate solutions. Additionally, the objective
function is non-convex. It is important to note that, depending on the initial guess,
the gradient descent method may sometimes converge to a critical point that does
not minimize the objective function.
Our model (5.10)–(5.12) can be interpreted as a shallow neural network x →
z → Y ., where x ∈ R4×3 . is the input layer, Y ∈ R4 . is the output layer, and z ∈ R4×3 .
is the hidden layer. The map from x to z is characterized by an activation (hyperbolic
tangent) function together with linear combinations of x determined by a parameter
matrix (q, r) ∈ R3×2 ., while the map from z to Y is characterized by an activation
(hyperbolic tangent) function together with a linear combination of z determined by
a parameter vector p ∈ R3 ..
Problems
5.1 Given x1 , x2 ∈ B = {1, −1}., prove that x1 ∨x2 = x2 ∨x1 . and x1 ∧x2 = x2 ∧x1 ..
5.2 Given x1 , x2 , x3 ∈ B = {1, −1}., prove that (x1 ∨ x2 ) ∨ x3 = x1 ∨ (x2 ∨ x3 ).
and (x1 ∧ x2 ) ∧ x3 = x1 ∧ (x2 ∧ x3 )..
5.3 Given x1 , x2 , x3 ∈ B = {1, −1}., prove that
5.5 Discussions 61
and
12
A=
. ,
34
Recall that the model of shallow neural network (5.10)–(5.12) is rewritten as a chain
of maps x → z → Y ., where x ∈ R4×3 . is the input layer, Y ∈ R4 . is the output layer,
and z ∈ R4×3 . is the hidden layer. Now we use a unified notation to denote a deep
neural network
where x (0) = x ∈ Rn×(d+1) . is the input layer and x (L) = (1n , Y ) ∈ Rn×(1+1) . with
1n := (1, · · · , 1)T ∈ Rn . is the output layer, while for each l = 1, · · · , L − 1.,
x (l) ∈ Rn×(dl +1) . with x10 = · · · = xn0 = 1. is the hidden layer. The dimension
(l) (l)
where p(l) ∈ R(dl +1)×dl+1 . is the parameter matrix connecting the l -th layer with the
(l + 1).-th layer. In other words, the above map can be written as
(l+1) 1, jl+1 = 0,
xijl+1 =
.
dl (l) (l) (6.3)
tanh( jl =0 xijl pjl jl+1 ), jl+1 = 1, · · · , dl+1 ,
Similar to the case of shallow neural network, we shall calculate the gradients
∂J /∂p(l) . for each l = 0, · · · , L − 1.. For convenience, we introduce the following
notations:
for each l = 0, · · · , L − 1.. The following formulas are elementary but crucial:
(L) (L)
(L−1) ∂J ∂xi1 xi1 − yi (L)
vi1
. = (L) (L−1)
= (L)
{1 − [xi1 ]2 } = Yi − yi , . (6.9)
∂xi1 ∂ui1 1 − [xi1 ]2
(l)
(l−1)
dl+1
∂J ∂uijl+1 dxij(l)l dl+1
(l ) (l) (l)
vijl = (l) (l) (l−1)
= vijl+1 pjl jl+1 {1 − [xijl ]2 },
jl+1 =1 ∂uijl+1 ∂xijl duijl jl+1 =1
(6.10)
6.3 Python Code 65
n (l) n
(l) ∂J ∂uijl+1 (l) (l)
.q
jl jl+1 = (l) (l)
= vijl+1 xijl , (6.11)
i=1 uijl+1 ∂pjl jl+1 i=1
v (L−1) =Y − y, .
. (6.12)
(1:n)×(1:dl )
v (l−1) ={v (l) [p (l) ]T } ∗ [1n×(dl +1) − x (l) ∗ x (l) ] , l = L − 1, · · · , 1, .
(6.13)
q (l) =[x (l) ]T v (l) , l = 0, · · · , L − 1. (6.14)
The gradient descent method is thus to replace p (l) . with p(l) − αq (l) . during each
iteration, where α > 0., as usual, denotes the learning rate. The neural network
notations are illustrated in Table 6.1.
The Python code for the (deep) neural network is given below:
66 6 Deep Neural Network
def neural_network(x,y,hidden_layers,al,iter_max):
n,m=[Link]
d=[m-1]+hidden_layers+[1]
L=len(d)-1
x=[x]+[None]*L
v=[None]*L
p=[None]*L
for l in range(L):
p[l]=[Link](0,1,(d[l]+1,d[l+1]))
for iter in range(iter_max):
for l in range(L):
u=[Link]([Link](x[l],p[l]))
x[l+1]=[Link](([Link]((n,1)),u),axis=1)
Y=x[L][:,1].reshape(n,1)
v[L-1]=Y-y
for l in range(L-1,0,-1):
v[l-1]=([Link](v[l],p[l].T)*(1-x[l]*x[l]))[:,1:]
for l in range(L):
p[l]=p[l]-al*[Link](x[l].T,v[l])
return Y,p
x=[Link]([[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1]])
y=[Link]([[-1],[1],[1],[-1]])
Y,p=neural_network(x,y,hidden_layers=[2],al=0.1,
iter_max=1000)
print(p)
print([Link]((Y,y),axis=1))
6.4 Discussions
In the Python code, we use the list data type to address the layers.
1. d is a list of L + 1. numbers, where d[l]. with l = 0, · · · , L. corresponds to the
dimension in l-th layer. In particular, d[0]. is the dimension of the input layer, and
d[L] = 1. is the dimension of the output layer.
6.4 Discussions 67
2. Forward propagation:
3. Backward propagation:
Simulation Result
[array([[-1.5815611 , 1.82134624],
[ 1.76355366, 1.97592353],
[-1.75918357, -1.96452545]]), array([[ 3.04703861],
[ 3.38373003],
[-3.36820299]])]
[[-0.997053 -1. ]
[ 0.99426201 1. ]
[ 0.99437418 1. ]
[-0.9970351 -1. ]]
With only one hidden layer of dimension 2, the simulation results align with
those of the shallow neural network discussed in the previous chapter. To adapt this
68 6 Deep Neural Network
code for a deeper neural network, we simply need to modify the list hidden_layer
by increasing the number of hidden layers and configuring them with varying
dimensions.
Problems
6.1 Let C = AB ., where A ∈ Rn×m ., B ∈ Rm×r ., and C ∈ Rn×r .. For each i =
1, · · · , n., j = 1, · · · , r ., k = 1, · · · , n., l = 1, · · · , m., s = 1, · · · , r ., prove that
∂Cij ∂Cij
. = δik Blj , = δj s Ail ,
∂Akl ∂Bls
where δik . (resp. δj s .) is the Kronecker delta symbol which equals 1 when i = k .
(respectively, j = s .) and 0 when i k . (respectively, j s .).
6.2 Verify (6.8).
6.3 Verify (6.9) and (6.10).
6.4 Verify (6.13).
6.5 Change the hidden layers in the Python code, and observe the simulation
results.
Chapter 7
Batch Normalization
where x (0) = x ∈ Rn×(d0 +1) . is the input layer and x (L) = (1n , Y ) ∈ Rn×(dL +1) .
(with dL = 1. and 1n = (1, · · · , 1)T ∈ Rn .) is the output layer, while for each
l = 1, · · · , L − 1., x (l) ∈ Rn×(dl +1) . is the hidden layer. The dimension of the l-th
layer (with l = 0, 1, · · · , L.) is denoted by dl .; in particular, d0 . is the number of
input features, and dL = 1. is the dimension of the output layer. The depth of the
neural network is denoted by L. The map x (l) → x (l+1) . (with l = 0, 1, · · · , L − 1.)
was defined in the previous chapter as a combination of an activation (generalized
sigmoid/hyperbolic tangent) function and a linear combination of x (l) . involving a
parameter matrix p(l) ∈ Rdl +1×dl+1 .. The key idea of batch normalization is to
introduce an additional step of normalization before taking the linear combination.
In other words, for each l = 0, 1, · · · , L − 1., i = 1, · · · , n., and jl = 0, · · · , dl ., we
define
(l) 1, jl = 0,
zijl =
.
(l) (l) (l) (7.2)
[xijl − μjl ]/σjl , jl = 1, · · · , dl ,
where
n
(l) 1 (l)
μjl =
. xijl (7.3)
n
i=1
n
(l) 1 (l) (l)
σj l =
. [xijl − μjl ]2 (7.4)
n
i=1
where p(l) ∈ R(dl +1)×dl+1 . is the parameter matrix connecting the l -th layer with the
(l + 1).-th layer, and 1n ∈ Rn . is the vector of 1s. The objective function is still given
by
n
J (p(0) , · · · , p (L−1) ) :=
. C(Yi , yi ), (7.7)
i=1
∂J
v (l) :=
. ∈ Rn×dl+1 , . (7.8)
∂u(l)
∂J
w (l) := (l) ∈ Rn×(dl +1) , . (7.9)
∂z
∂J
q (l) := (l) ∈ R(dl +1)×dl+1 , (7.10)
∂p
7.2 Backward Propagation 71
∂μ(l)
jl
(l)
1 ∂σjl xij(l)l − μ(l)
jl
(l)
zij
.
(l)
= , = = l
, (7.11)
∂xijl n ∂x (l) nσ
(l) n
ijl jl
and
(l) (l) (l) (l) (l) (l)
∂zi jl δii − 1/n xi jl − μjl zijl nδii − 1 − zijl zi jl
.
(l)
= (l)
− (l)
· = (l)
, (7.12)
∂xijl σj l [σjl ]2 n nσjl
where δii . is the Kronecker delta symbol which equals 1 when i = i . and 0 when
i i ..
Similar to (6.8), we also need the following formulas:
(l) (l)
∂uijl+1 (l)
∂uijl+1 (l)
.
(l)
= pjl jl+1 , (l)
= zijl , (7.13)
∂zijl ∂pjl jl+1
(l)
(l)
dxijl (l)
.r
ijl := (l−1)
= 1 − [xijl ]2 , (7.14)
duijl
(L) (L)
(L−1) ∂J ∂xi1 xi1 − yi (L)
vi1
. = (L) (L−1)
= (L)
{1 − [xi1 ]2 } = Yi − yi , . (7.16)
∂xi1 ∂ui1 1 − [xi1 ]2
(l) (l) (l) (l)
(l−1)
n
∂J ∂zi jl dxijl
n
(l)
nδii − 1 − zijl zi jl (l)
vijl = (l)
= w i jl rijl , (7.17)
i =1 ∂zi jl ∂xij(l)l du(l−1)
ijl i =1 nσj(l)
l
72 7 Batch Normalization
n (l) n
(l) ∂J ∂uijl+1 (l) (l)
.q
jl jl+1 = (l) (l)
= vijl+1 zijl , (7.18)
i=1 uijl+1 ∂pjl jl+1 i=1
def append(A):
return [Link](([Link](([Link][0],1)),A),axis=1)
def cut(A):
return A[:,1:]
def ave(A):
n=[Link][0]
(continued)
7.4 Discussions 73
return [Link]([Link]((n,n)),A)/n
def batch_normalization(x,y,hidden_layers,al,iter_max):
n=[Link][0]
d=[[Link][1]-1]+hidden_layers+[1]
L=len(d)-1
p,v,z,mu,s=[None]*L,[None]*L,[None]*L,[None]*L,[None]*L
x=[x]+[None]*L
for l in range(L):
p[l]=[Link](0,1,(d[l]+1,d[l+1]))
for iter in range(iter_max):
for l in range(L):
mu[l]=sum(cut(x[l]))/n
s[l]=[Link](sum((cut(x[l])-mu[l])**2)/n)
z[l]=append((cut(x[l])-mu[l])/s[l])
x[l+1]=append([Link]([Link](z[l],p[l])))
Y=x[L][:,1].reshape(n,1)
v[L-1]=Y-y
for l in range(L-1,0,-1):
w=[Link](v[l],p[l].T)
r=cut(1-x[l]*x[l])
v[l-1]=cut(w-ave(w)-z[l]*ave(z[l]*w))*r/s[l]
for l in range(L):
p[l]=p[l]-al*[Link](z[l].T,v[l])
return Y,p,mu,s
x=[Link]([[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1]])
y=[Link]([[1],[-1],[-1],[1]])
hidden_layers=[2]
Y,p,mu,s=batch_normalization(x,y,hidden_layers,0.1,1000)
print([Link]((Y,y),axis=1))
7.4 Discussions
In the Python code, we have introduced three auxiliary functions to simplify the
expressions in the main function:
1. The append function is defined as appending a column of ones to the left of
a given matrix. For instance, given an input matrix A ∈ Rn×d ., the output of
append function is the matrix (1n , A) ∈ Rn×(d+1) ..
74 7 Batch Normalization
2. The cut function is defined as deleting the most left column of a given matrix.
It is clear that cut (append(A)) = A., but the equation append(cut (A)) = A. is
not valid unless the first column of A is a column of ones.
3. The ave function is defined as a matrix of identical rows with each row being the
column average of a given matrix. For instance, given A ∈ Rn×d ., the output of
ave function is the matrix (1n , · · · , 1n )A ∈ Rn×d ..
Problems
n n
7.1 Given μ = 1
n i=1 xi . and σ = 1
n i=1 (xi − μ)2 ., prove that
∂μ 1 ∂σ xi − μ
. = , = .
∂xi n ∂xi nσ
n n
7.2 Given μ = 1
n i=1 xi ., σ = 1
n i=1 (xi − μ)2 ., and zi = (xi − μ)/σ ., prove
that
∂zi nδii − 1 − zi zi
. = ,
∂xi nσ
where
1, i=i,
.δii =
0, i i.
Abstract Given two finite sets of real numbers, S+ . and S− ., where all numbers in
S+ . are positive and all numbers in S− . are negative, one can always select a threshold
value (e.g., 0) that separates the two sets, placing all negative numbers to its left and
all positive numbers to its right. Among infinitely many such thresholds, there exists
an optimal threshold that maximizes the minimal distance from all points in S± . to
the threshold. This optimal threshold forms the foundation of the support vector
machine (SVM). In this chapter, we extend this idea to higher dimensional spaces,
Rd ., and discuss two equivalent optimization formulations for SVMs.
8.1 Notations
Let x ∈ Rn×(d+1) . be the input feature matrix of size n and dimension d, where
xi0 = 1. for i = 1, · · · , n.. Assume that the observation vector is binary y ∈ {1, −1}n .
such that yi ∈ {1, −1}.. For each Xi = (xi0 , · · · , xid )T ∈ Rd+1 ., we denote X̂i =
(xi1 , · · · , xid )T ∈ Rd .. Let p = (p0 , · · · , pd )T ∈ Rd+1 . be the parameter vector.
√ p̂ = (p1 , · · · , pd ) ∈ R .. For any vector u ∈ R ., the norm is
Similarly, we denote T d d
t, t ≥ 0,
t+ := max{t, 0} =
. (8.1)
0, t ≤ 0.
d
Yi = (xp)i =
. xij pj = XiT p = p0 + X̂iT p̂.
j =0
A parameter vector p ∈ D . is called feasible in the sense that yi (xp)i ≥ 1. for each
i = 1, · · · , n.. It is easily seen that if p ∈ D ., so is cp for any c ≥ 1.. Throughout this
chapter, we assume that the given data {x, y}. is separable; namely, the feasible set
D is non-empty. We also assume that the data is nontrivial: There exist i and j such
that yi = yj .. The normalized feasible set is defined as
E := {p/ p
. p ∈ D}. (8.3)
In other words, E is the set of normalized feasible parameter vectors such that
p 1. and yi (xp)i > 0. for all i = 1, ·, n..
Any parameter vector p ∈ Rd+1 . with p > 0. defines a hyperplane in Rd .:
H (p) := {u ∈ Rd : p0 + uT p̂ = 0}.
. (8.4)
|p0 + uT p̂|
d(u, H (p)) := min
. u−v . (8.5)
v∈H (p) p
Given a nontrivial separable data x ∈ Rn×(d+1) . and y ∈ {1, −1}n ., we minimize the
objective function
n d
λ
J (p) :=
. C(Yi , yi ) + pj2 , (8.6)
2
i=1 j =1
∂J −yi , yi Yi < 1,
. = (8.8)
∂Yi 0, yi Yi > 1,
and
∂J
. =− yi xij + λ(1 − δj 0 )pj , (8.9)
∂pj
yi Yi <1
8.2 Optimization Problems 77
where δj 0 . is the Kronecker delta symbol that equals 1 when j = 0. and 0 when
j 0.. The gradient descent method is given by
(k+1) (k)
pj
. = [1 − αλ(1 − δj 0 )]pj + α yi xij , (8.10)
yi Yi <1
d
J1 (p)
. p pj2 (8.11)
j =1
is minimized.
Proposition 8.1 Assume that the data {x, y}. is nontrivial and separable. The
objective function J1 (p). in (8.11) possesses at least one minimizer, denoted by p ∗ .,
in D .
Proof Since the data is separable, the feasible set D is non-empty. Choose any
q ∈ D ., and denote
d
r :=
. qj2 .
j =1
Since the data is nontrivial, we have r > 0.. Moreover, there exist i1 . and i2 . such that
yi1 = 1. and yi2 = −1.. For any p ∈ D . with p r ., we have p0 + X̂iT1 p̂ ≥ 1. and
p0 + X̂iT2 p̂ ≤ −1.. Consequently,
p0 ≥ 1 − X̂iT1 p̂ ≥ 1 − r X̂i1 ,
.
78 8 Support Vector Machine
and
p0 ≤ −1 − X̂iT2 p̂ ≤ −1 + r X̂i2 .
.
Dr := {p ∈ D
. p r}
is bounded. It is easily seen that Dr . is also closed. Hence, the objective function J1 .
possesses a minimizer, denoted by p∗ ., in Dr ., with J1 (p∗ ) ≤ r .. Since J1 (p) > r .
for all p ∈ D \ Dr ., we have J1 (p∗ ) ≤ J1 (p). for all p ∈ D .. This completes the
proof.
Lemma 8.1 For any p ∈ D ., we have
Proof For any p ∈ D . and i = 1, · · · , n., we have yi (p0 + X̂iT p̂) ≥ 1.. Since the data
is nontrivial, we also have p > 0.. Consequently, |p0 +X̂iT p̂| = yi (p0 +X̂iT p̂) ≥ 1.
and
is maximized.
Proposition 8.2 Assume that the data {x, y}. is nontrivial and separable. The
objective function J2 (p). in (8.13) possesses at least one minimizer, denoted by p∗∗ .,
in E .
Proof The conclusion follows from the fact that E is compact and J2 . is continuous.
8.3 Equivalence Theorem 79
We will prove that the two constrained optimization problems are equivalent.
Theorem 8.1 The constrained optimization problem I has a unique minimizer p∗ ∈
D ., and the constrained optimization problem II has a unique maximizer p ∗∗ ∈ E ..
Moreover, we have
p∗ 1
p∗∗ =
. , J1 (p∗ ) = . (8.14)
p∗ J2 (p∗∗ )
Proof On account of Proposition 8.1 and Proposition 8.2, there exist p∗ ∈ D . and
p ∗∗ ∈ E . such that J1 (p∗ ) ≤ J1 (p). for all p ∈ D . and J2 (p∗∗ ) ≥ J2 (p). for all
p ∈ E .. For any p ∈ E ., we have yi (p0 + X̂iT p̂) > 0. for all i = 1, · · · , n.. Hence,
we obtain
where
.J2+ (p) = min (p0 + X̂iT p̂) = p0 + min (X̂iT p̂), . (8.16)
yi =1 yi =1
J2− (p) = min (−p0 − X̂iT p̂) = −p0 + min (−X̂iT p̂). (8.17)
yi =−1 yi =−1
1
g(u) :=
. [ min (−X̂iT u) − min (X̂iT u)], u ∈ Rd .
2 yi =−1 yi =1
1
.f (u) := [ min (−X̂iT u) + min (X̂iT u)], (8.18)
2 yi =−1 yi =1
for u ∈ Rd .. It follows from the above argument that J2 (p∗∗ ) = f (p̂ ∗∗ ).. Moreover,
by definition, we observe that
80 8 Support Vector Machine
for any c > 0. and u, v ∈ Rd .. Since p 1. and f (p̂) > 0. for p ∈ E ., the function
f (u). has a unique maximizer on the unit sphere S := {u ∈ Rd , u 1}..
We show that the maximizer of f on S is exactly p̂∗∗ .. This is because for any
u ∈ S . with f (u) > 0., we may choose p ∈ Rd+1 . with p̂ = u. and p0 = g(u).
such that p ∈ E . and J2 (p) = J2+ (p) = J2− (p) = f (p̂)., and hence f (p̂ ∗∗ ) =
J2 (p∗∗ ) ≥ J2 (p) = f (p̂) = f (u).. On the other hand, if u ∈ S . with f (u) ≤ 0., then
f (p̂ ∗∗ ) > 0 ≥ f (u).. This proves that p̂ ∗∗ . is the unique maximizer of f on S. In
view of p0∗∗ = g(p̂∗∗ )., the maximizer of J2 . is also unique.
Finally, since p ∗ /J1 (p∗ ) ∈ E . and p∗∗ /J2 (p∗∗ ) ∈ D ., we have
1 1
J2 (p∗∗ ) ≥ J2 (p∗ /J1 (p∗ )) ≥
. ≥ = J2 (p∗∗ ).
J1 (p∗ ) J1 (p∗∗ /J2 (p∗∗ ))
The above inequalities should be equalities, and the identities (8.14) are proved.
Finally, the uniqueness of p ∗ . follows from the uniqueness of p∗∗ ..
Problems
8.1 Given p ∈ Rd+1 . with p > 0.. Let H (p). be the hyperplane defined in (8.4).
For any u ∈ Rd ., prove that
|p0 + uTp̂|
. min u−v .
v∈H (p) p
8.2 Verify that H (p) = H (cp). for any c 0. and p ∈ Rd+1 . with p > 0..
8.3 Given Yi ∈ R. and yi ∈ {1, −1}., prove that
(1 + yi )(1 − Yi )+ + (1 − yi )(1 + Yi )+
. = (1 − yi Yi )+ .
2
8.4 Assume that D in (8.2) is non-empty. Prove that J (p) = λ p 2 /2. for all p ∈
D ..
8.5 Prove that the data {x, y}. is nontrivial if and only if p > 0. for any p ∈ D ..
8.6 Assume that the data {x, y}. is nontrivial and separable. Prove that the feasible
set D defined in (8.2) is closed in Rd+1 ..
8.7 Assume that the data {x, y}. is nontrivial and separable. Prove that the normal-
ized feasible set E defined in (8.3) is compact (i.e., bounded and closed) in Rd+1 ..
8.8 Show that p/J2 (p) ∈ D . if p ∈ E ..
8.9 Prove that E defined in (8.3) is the same as
E = {p ∈ Rd+1
. p 1, yi (xp)i > 0, i = 1, · · · , n}.
8.3 Equivalence Theorem 81
8.10 Let E and f be defined as in (8.3) and (8.18), respectively. Prove that f (p̂) >
0. for any p ∈ E ..
8.11 Verify (8.19).
8.12 Assume h ∈ C(Rd , R). is convex and h(cu) = ch(u). for any c > 0. and
u ∈ Rd .. If the minimum of h on the unit sphere S = {u ∈ Rd u 1}. is
negative, prove that the minimizer on S is unique.
Chapter 9
Gradient Methods
Let A ∈ Rm×m . be a symmetric and positive definite matrix. We may define an inner
product on Rm . as
(u, w) = uT Aw, u, w ∈ Rm .
. (9.1)
Av = b.
. (9.2)
(e1 , u1 )
e2 = e1 − α1 u1 , α1 =
. .
(u1 , u1 )
(r2 , u1 )
u2 = r2 −
. u1
(u1 , u1 )
rk+1 = Aek+1 ,
. (9.3)
with
(ek , uk )
ek+1 = ek − αk uk , αk =
. . (9.4)
(uk , uk )
k
(rk , uj )
.uk+1 = rk+1 − uj (9.5)
(uj , uj )
j =1
such that
. Sk(1) := span{r1 , r2 , · · · , rk },
(2)
Sk := span{u1 , u2 , · · · , uk },
(3)
Sk := span{r1 , Ar1 , · · · , Ark−1 },
(4)
Sk := span{u1 , Au1 , · · · , Auk−1 }.
9.1 Conjugate Gradient Method 85
for k = 1.. Now, we assume that the above identities are true for all k = 1, · · · , K ..
(1) (2) (3) (4)
In view of (9.5), we have Sk = Sk . and Sk = Sk . for k = K + 1.. Moreover,
since
by (9.4), we also have Sk(1) = Sk(4) . for k = K + 1.. Therefore, the four vector spaces
are identical for k = K + 1.. This completes the proof.
On account of Proposition 9.1, we denote
Sk := span{r1 , r2 , · · · , rk } = span{u1 , u2 , · · · , uk }
.
rkT uj = (ek , uj ) = 0, .
. (9.8)
(rk+1 , uj ) = (ek+1 , Auj ) = 0. (9.9)
Proof If k = 2., then (9.4) implies that r2T u1 = (e2 , u1 ) = 0.. Now, we assume
that (9.8) holds for any 1 ≤ j < k ≤ K .. By (9.6) and (9.4), we have (ek+1 , uk ) = 0.
and
uk+1 = rk+1 + βk uk ,
. (9.10)
where
(rk+1 , uk ) r T (rk+1 − rk ) T r
rk+1 k+1
.βk := − = k+1 = . (9.11)
(uk , uk ) uk (rk − rk+1 )
T T
rk r k
vk+1 = vk − αk uk ,
. (9.12)
where
(ek , uk ) r T rk
αk =
. = Tk . (9.13)
(uk , uk ) uk Auk
Output: vk .
Theorem 9.1 If u1 , · · · , um . are nonzero vectors, then rm+1 = 0., em+1 = 0., and
vm+1 = v ..
Proof Since (uk , uj ) = 0. for j < k ., the nonzero vectors u1 , · · · , um . are
orthogonal to each other. Hence, Sm = span{u1 , · · · , um } = Rm . and u1 , · · · , um .
are orthogonal basis in Rm .. By (9.9), we have (rm+1 , uj ) = 0. for all j = 1, · · · , m..
Consequently, rm+1 = 0., which implies em+1 = A−1 rm+1 = 0. and vm+1 =
v + em+1 = v .. This completes the proof.
Here, α > 0. is the learning rate. If α = 1. and Djj = Ajj . for j = 1, · · · , m., then
the above iteration is called the Jacobi method. If D = I . and A is a positive definite
symmetric matrix, then the above iteration is the gradient descent method for the
optimization problem of minimizing the quadratic function
1 T
Q(v) :=
. v Av − v T b.
2
Let ek = vk − v . be the error vector. The iteration (9.14) is rewritten as
J1 (α) := ρ(I − αD −1 A) =
. max |1 − αλj |. (9.16)
j =1,··· ,m
If α > 0. is sufficiently small, say α < 1/λm ., then J1 (α) < 1. and ek → 0. as k →
∞.. To obtain a fast convergence rate, we shall investigate the following minimax
optimization problem.
λ m − λ1
J1 (α) > J1 (α ∗ ) =
. (9.17)
λ m + λ1
J1 (α ∗ ) = (λm − λ1 )/(λm + λ1 ).
.
88 9 Gradient Methods
If α > α ∗ ., then
ek+1 (1 + β)I − αD −1 A − βI ek
. = . (9.20)
ek I 0 ek−1
(1 + β)I − αD −1 A − βI
.
I 0
are
1 + β − αλj ± (1 + β − αλj )2 − 4β
. , j = 1, · · · , m.
2
This motivates us to consider the following minimax optimization problem.
9.3 Two-Step Method 89
J2 (α, β) :=
. max ρj (α, β) (9.21)
j =1,··· ,m
is minimized, where
|1 + β − αλj | + (1 + β − αλj )2 − 4β
ρj (α, β) :=
. (9.22)
2
(1 + β)I − αλj −β
. .
1 0
We have
√ √
λm − λ1
J2 (α, β) > J2 (α ∗ , β ∗ ) = √
. √ (9.24)
λm + λ1
and
√ √
λm − λ1
.J2 (α ∗ , β ∗ ) = ρ1 (α ∗ , β ∗ ) = ρm (α ∗ , β ∗ ) = √ √ .
λm + λ1
1 + β − αλ1 1 + β ∗ − α ∗ λ1
J2 (α, β) ≥ρ1 (α, β) ≥
. > = J2 (α ∗ , β ∗ ).
2 2
1 + β − αλm 1 + β ∗ − α ∗ λm
J2 (α, β) ≥ρm (α, β) ≥ −
. >− = J2 (α ∗ , β ∗ ).
2 2
1 + β − αλ1 + (1 + β − αλ1 )2 − 4β
J2 (α, β) ≥ρ1 (α, β) =
.
2
1 + β − α ∗ λ1 + (1 + β − α ∗ λ1 )2 − 4β
≥
2
1 + β ∗ − α ∗ λ1 + (1 + β ∗ − α ∗ λ1 )2 − 4β ∗
> = J2 (α ∗ , β ∗ ).
2
Problems
9.1 Let rk ., ek ., and uk . be defined recursively from (9.3), (9.4), and (9.5). Prove that
T r = 0., r T u = 0., and uT r = r T r ..
rk+1 k k+1 k k k k k
9.2 Verify (9.11) and (9.13).
9.3 Prove that if the iteration (9.14) converges, then the limit is a solution to the
linear system Av = b..
9.4 Verify (9.15).
9.5 Given α > 0. and 0 < λ1 < λm ., prove that the function fα (λ) = |1 − αλ|. is a
convex function, and its maximum value on [λ1 , λm ]. is achieved at either λ1 . or λm ..
9.6 Given x ∈ Rn×(d+1) . and y ∈ Rn . with det(x T x) 0., show that the minimizer
of the error SSE xp − y 22 . can be approximated by the iteration (9.14) where
D = I ., A = x T x ., b = x T y ., and the learning rate α > 0. is chosen to be sufficiently
small.
9.7 Let 0 < λ1 ≤ · · · ≤ λm . be the eigenvalues of D −1 A.; prove that the eigenvalues
of the block matrix
9.3 Two-Step Method 91
(1 + β)I − αD −1 A − βI
.
I 0
are
1 + β − αλj ± (1 + β − αλj )2 − 4β
. , k = 1, · · · , m.
2
9.8 Given α > 0., β ≥ 0., and λj > 0., show that ρj (α, β). defined in (9.22) is the
spectral radius of the matrix
(1 + β)I − αλj −β
. .
1 0
9.9 Given 0 < λ1 < λm ., let α ∗ . and β ∗ . be defined as in (9.23). For any λj ∈
(λ1 , λm )., prove that
√ √
λm − λ1
ρj (α ∗ , β ∗ ) < ρ1 (α ∗ , β ∗ ) = ρm (α ∗ , β ∗ ) = √
. √ ,
λm + λ1
f (β) := 1 + β − α ∗ λ1 +
. (1 + β − α ∗ λ1 )2 − 4β
Abstract This chapter presents the theory of singular value decomposition (SVD)
and principal component analysis (PCA), which are fundamental tools for ana-
lyzing and approximating high-dimensional data. We begin by reviewing the
Schur decomposition for square matrices and unitary transformations, laying the
groundwork for understanding SVD. The chapter then introduces singular value
decomposition, proving its existence, uniqueness, and the relationship between
singular values and the eigenvalues of AT A. and AAT .. Building on SVD, we develop
principal component analysis as a method for dimensionality reduction. We define
the Rayleigh quotient and formulate a sequence of optimization problems whose
solutions yield the principal components of a given matrix. The chapter establishes
the orthogonality of left and right singular vectors and demonstrates that the sum
of the first k principal components provides the best rank-k approximation of the
original matrix in the Frobenius norm.
λ1 α1H
AU1 = U1
. ,
0 A2
λ1 α1H
A = U1
. U1H .
0 U2 T2 U2H
λ1 α1H 1 0 λ1 α1H U2 1 0
. = ,
0 U2 T2 U2H 0 U2 0 T2 0 U2H
we obtain A = U T U H ., where
1 0
U=
.
0 U2
is unitary and
λ1 α1H U2
T =
.
0 T2
Theorem 10.2 For any matrix A ∈ Cm×n ., there exist a unitary matrix U ∈ Cm×m .,
a unitary matrix V ∈ Cn×n ., and a rectangular diagonal matrix Σ ∈ Cm×n . with
nonnegative diagonal terms, such that A = U ΣV H .. We may order the diagonal
terms of Σ . such that Σjj ≥ Σkk . for 1 ≤ j < k ≤ min{m, n}..
Proof Without loss of generality, we may assume that m ≤ n. and A is of rank m;
namely, AAH ∈ Cm×m . is a positive definite Hermitian matrix. There exist a unitary
matrix U ∈ Cm×m . and a diagonal matrix D ∈ Cm×m . with positive diagonal terms
such that AAH = U D 2 U H .. In particular, we may order the diagonal terms of D as
D11 ≥ D22 ≥ · · · ≥ Dmm > 0.. Set V1 = AH U D −1 ∈ Cn×m .. It is easily seen that
A = U DV1H . and
10.3 Principal Component Analysis 95
.V1H V1 = D −1 U H AAH U H D −1 = D −1 D 2 D −1 = I.
v T AT Av Av 22
R1 (v) :=
. = , (10.1)
vT v v 22
n n
.R1 (v) = v T AT Av = λj cj2 ≤ λ1 cj2 = λ1 = R1 (v1 ).
j =1 j =1
Pk := Avk vkT .
. (10.2)
v T ATk Ak v Ak v 22
Rk (v) :=
. = , (10.3)
T
v v v 22
k−1 k−1
Ak := A −
. Pj = A − Avj vjT . (10.4)
j =1 j =1
k−1
A=
. Pj . (10.5)
j =1
min{m,n}
A=
. Pj . (10.6)
j =1
k
. u−w 2
2 u 2
2 − (uT wj )2 ,
j =1
k
.w= (uT wj )wj
j =1
is the projection of u on W .
Proof If k = 1., then
. u − cw1 2
2 = c2 − 2(uT w1 )c + uT u u 2
2 − (uT w1 )2 ,
k k−1 k
. u− cj wj 2
2 u− cj wj 2
2 − (uT wk )2 u 2
2 − (uT wj )2 ,
j =1 j =1 j =1
bj = (w1 , · · · , wk )T ej , j = 1, · · · , k − 1.
.
Since the subspace spanned by these vectors has a dimension less than k, there
exists a vector c = (c1 , · · · , ck )T ∈ Rk . such that c 2 = 1. and cT bj = 0. for all
j = 1, · · · , k − 1.. This implies that Bc = 0.. By choosing
.w = w1 c1 + · · · + wk ck ∈ Rn ,
10.3 Principal Component Analysis 99
we obtain
ejT w = Bj 1 c1 + · · · + Bj k ck = (Bc)j = 0
.
m n
. B F := |Bj k |2 . (10.7)
j =1 k=1
k
. al − bl 2
2 al 2
2 − (alT wj )2 ,
j =1
k
bl =
. (alT wj )wj
j =1
100 10 Dimensionality Reduction
m m k k
. A−B 2
F ≥ al 2
2 − (alT wj )2 A 2
F − Awj 2
2.
l=1 l=1 j =1 j =1
n k n
. A−B 2
F ≥ λj − λj = λj ,
j =1 j =1 j =k+1
k
bl =
. (alT vj )vj ;
j =1
namely,
k k
B=
. Avj vjT = Pj .
j =1 j =1
Problems
10.1 For any u1 ∈ Cn . with u1 2 = 1., show that there exist normalized
orthonormal vectors u2 , · · · , um ∈ Cm . such that U1 = (u1 , · · · , um ) ∈ Cm×m .
is unitary.
10.2 Verify
λ1 α1H 1 0 λ1 α1H U2 1 0
. = .
0 U2 T2 U2H 0 U2 0 T2 0 U2H
10.5 Assume m ≤ n.. For any V1 ∈ Cn×m . with V1H V1 = I ., prove that there exists
V2 ∈ Cn×(n−m) . such that V H = (V1H , V2H ) ∈ Cn×n . is unitary.
10.6 Compute the eigenvalues and singular values of the matrix
12
A=
. .
01
10.7 Let A ∈ Rm×n . with the first Rayleigh quotient R1 (v). defined as in (10.1).
For any nonzero vector v ∈ Rn . and its normalization w = v/ v 2 .. Prove that
R1 (v) = R1 (w) Aw 22 ..
10.8 Given A ∈ Rm×n ., let Ak ∈ Rm×n . defined as in (10.4). Prove that
k−1
ATk Ak = AT A −
. λj vj vjT .
j =1
10.9 Given any vectors b1 , · · · , bk−1 ∈ Rk ., prove that there exists a vector u ∈ Rk .
such that u 2 = 1. and uT bj = 0. for all j = 1, · · · , k − 1..
10.10 Given A ∈ Rm×n ., let a1 , · · · , am ∈ Rn . be the column vectors of AT .. Prove
that
m
. AT 2F A 2
F = aj 2
2.
j =1
Appendix A
Related Topics
In this appendix, we review some related topics and results from calculus and linear
algebra.
A.1 Calculus
We say an infinite sequence {xn }∞n=1 ⊂ R. converges to c if for any ε > 0., there
exists N ∈ N. such that |xn − c| < ε. for all n > N .. In this case, we denote
. lim xn = c.
n→∞
The sequence {xn }∞n=1 ⊂ R. is called a Cauchy sequence if for any ε > 0., there
exists N ∈ N. such that |xn − xm | < ε. for all n > N . and m > N ..
Theorem A.1 The real line R. is complete; namely, the following statements are
equivalently valid:
(i) Every Cauchy sequence converges.
(ii) Every bounded and monotone sequence is convergent.
(iii) Every bounded sequence has a convergent subsequence.
(iv) Every non-empty bounded set has a supremum (least upper bound) and an
infimum (greatest lower bound)
Given a non-empty set A ⊂ R., we say a ∈ R. is a limit point of A if there exists an
infinite sequence {xn }∞n=1 ⊂ A. that converges to a: xn → a . as n → ∞.. The closure
of A, denoted by Ā., is the set containing all limit points of A. Since any point in A
is a limit point (by choosing xn = a . for all n = 1, 2, · · · .), we have A ⊂ Ā.. We say
A is closed if A = Ā..
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2026 103
X.-S. Wang, C. Wang, Machine Learning in Data Processing, Forum for
Interdisciplinary Mathematics, [Link]
104 A Related Topics
Theorem A.2 A set A ⊂ R. is a closed and bounded set if and only if it is compact;
namely, any sequence in A has a subsequence that converges to a point in A.
Let f be a (real-valued) function defined on an open interval I = (a, b) ⊂ R.,
where a could be either finite or − ∞., and b could be either finite or ∞.. Given
c ∈ I ., we say f (x) → L. as x → c. if for any small ε > 0., there exists δ > 0. such
that 0 < |x − c| < δ . implies |f (x) − f (c)| < ε .. The value L is called the limit
of f (x). at c. The one-sided limits of f (x). at c can be defined in a similar manner.
We say f (x) → L. as x → c+ . (respectively, x → c− .) if for any small ε > 0., there
exists δ > 0. such that 0 < x − c < δ . (respectively, − δ < x − c < 0.) implies
|f (x) − f (c)| < ε .. We use
respectively, to denote the limit, right limit, and left limit of f (x). at c. It is evident
that the limit exists if and only if both one-sided limits exist and equal. We say f is
continuous at c if
One can prove that f is continuous at c if and only if for any convergent sequence
{xn }∞
n=1 ⊂ R. with limn→∞ xn = c., we have limn→∞ f (xn ) = f (c).. We say f is
differentiable at c if the limit
f (x) − f (c)
. lim
x→c x−c
exists, and in this case, we denote the value of the limit by f (c). and call it the
derivative of f at c. If f is continuous for each x ∈ I ., then we say f is continuous
on I . The set of all continuous functions on I is denoted by C(I ) = C(I, R).. When
the end points a and b are finite, we say f is continuous on I¯ = [a, b]. if f is
continuous on I = (a, b). and
(ii) (Extreme Value Theorem) Let M and m be the supremum and infimum of f (I¯).,
respectively. There exist xM , xm ∈ I¯. such that f (xM ) = M . and f (xm ) = m..
(iii) (Intermediate Value Theorem) For any r ∈ (m, M)., where M and m are given
as above, there exists c ∈ (a, b). such that f (c) = r ..
(iv) (Mean Value Theorem) If further f ∈ C 1 (I )., then there exists ξ ∈ (a, b). such
that f (ξ ) = [f (b) − f (a)]/(b − a)..
Differentiation is a linear operator from C 1 (I ). to C(I ).; namely
(c1 f1 + c2 f2 ) = c1 f1 + c2 f2 ,
. (A.1)
for any c1 , c2 ∈ R. and f1 , f2 ∈ C 1 (I ).. The product rule and the quotient rule of
differentiation are
(f g) = f g + f g , (f/g) = (f g − fg )/g 2 ,
. (A.2)
for f, g ∈ C 1 (I ).. If g ∈ C 1 (I ). and f ∈ C 1 (g(I ))., we also have the chain rule
b b
. f (x)dx = F (x) = F (b) − F (a), (A.4)
a a
where the left-hand side is called a definite integral of f (x). over the interval I =
(a, b).. If f, g ∈ C 1 (I ) ∩ C(I¯)., then the product rule of differentiation (A.2) implies
the useful formula of integration by parts:
b b b
. f (x)g(x)dx = f (x)g(x) − f (x)g (x)dx. (A.5)
a a a
Theorem A.4 (Taylor’s Theorem) Let f ∈ C (n+1) (I ). with I = (a, b).. For any
x, x0 ∈ (a, b)., we have f (x) = Pn (x) + Rn (x)., where
n
f (k) (x0 )
Pn (x) =
. (x − x0 )k (A.6)
k!
k=0
is the remainder/error term. Moreover, there exists ξ ∈ (a, b). (depending on x and
x0 .) such that
(x − x0 )n+1 (n+1)
Rn (x) =
. f (ξ ). (A.8)
(n + 1)!
A matrix A ∈ Cm×n . is a set of m×n. complex numbers with the following structure:
⎛ ⎞
A11 · · · A1n
⎜ . .. ⎟ .
.A = ⎝ .
. . ⎠
Am1 · · · Amn
1, i = j,
Iij = δij =
.
0, i j,
A11 , n = 1,
. det(A) = n j −1 A det(A(1,j ) ), n > 1,
j =1 (−1) 1j
where A(i,j ) ∈ C(n−1)×(n−1) . is the submatrix obtained by deleting the i-th row and
the j -th column in A. The trace of a square matrix A ∈ Cn×n . is defined as the sum
of diagonal terms:
n
. tr(A) := Ajj .
j =1
.c1 v1 + · · · + cn vn = 0 ∈ Cn .
In other words, the vectors v1 , · · · , vn . are linearly independent if and only if the
above equation has only one trivial solution c1 = · · · = cn = 0.. If the vectors
v1 , · · · , vk ∈ Cn . are linearly independent, then we can define a k-dimensional
subspace Vk ∈ Cn . spanned by these vectors as follows:
n n
. u 1 := |ui |, u 2 := |ui |2 , u ∞ := max |ui |.
i
i=1 i=1
have u ∞
√ u 2 ≤ n u ∞ ., u ∞ u 1 ≤ n u ∞ ., and u 2 u 1 ≤
n u 2 . for all u ∈ Cn ..
A Related Topics 109
m n
. A F := |Aj k |2 = tr(AH A) = tr(AAH ), A ∈ Cm×n .
j =1 k=1
In many cases, we mainly focus on matrix norms of square matrices. In this case,
we always scale the norm such that it satisfies
. AB A B , (A.9)
|λ B
. λB AB A B ,
. on C
n×n . that is defined by
Au
. A sup = sup Av ,
u∈Cn , u 0 u v∈Cn , v 1
for any A ∈ C n×n .. The most commonly used matrix norms are l p .-norms with
p = 1, 2, ∞.:
n
. A 1 := sup Av 1 = max |Aj k |,
v∈Cn , v 1 =1 1≤k≤n
j =1
n
A ∞ := sup Av ∞ = max |Aj k |.
v∈Cn , v ∞ =1
1≤j ≤n
k=1
is
Dn = aeiθ + be−iθ ,
.
. det(B) = c (xj − xk ),
1≤k<j ≤n
where c is a constant.
2.4 Define f (t) := J (p+t (q−p)). for t ∈ [0, 1]., and then apply Taylor’s theorem.
3.7 Fix u ∈ I .. For any sufficiently small ε > 0., the function g(h) := [f (u + h) −
f (u)]/ h. is monotone and bounded for h ∈ (0, ε]. and also for h ∈ [−ε, 0)..
4.7 Apply Taylor’s theorem to the function f (α) := J (p − αJ (p))..
5.3 Note that (x1 ∨ x2 ) ∧ x3 = 1. if and only if x1 ∨ x2 = 1. and x3 = 1., which is
equivalent to x1 ∧ x3 = 1. or x2 ∧ x3 = 1.. The other identity can be proved in
a similar manner.
6.1 If i k ., then Cij . is independent of Akl .. If i = k ., then from
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2026 111
X.-S. Wang, C. Wang, Machine Learning in Data Processing, Forum for
Interdisciplinary Mathematics, [Link]
112 B Hints to Selected Exercise Problems
m
Cij =
. Ail Blj
l=1
we obtain
∂Cij
. = Blj .
Ail
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2026 113
X.-S. Wang, C. Wang, Machine Learning in Data Processing, Forum for
Interdisciplinary Mathematics, [Link]
References
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2026 115
X.-S. Wang, C. Wang, Machine Learning in Data Processing, Forum for
Interdisciplinary Mathematics, [Link]
Index
B cost, 48
Backward propagation, 64, 71 differentiable, 104
Batch normalization, 69 Fréchet differentiable, 12
gradient, 12
inner product, 83, 108
C likelihood, 19
Cauchy sequence, 103 multilinear, 3
Coefficient of determination, 24, 32 normalized, 3
Conjugate gradient method, 83 sigmoid, 46
Convex optimization, 34
Covariance, 19
G
Gradient descent method, 49, 58
D Gram-Schmidt process, 84, 93
Data
dimension, 17
nontrivial, 76 H
separable, 76 Hyperplane, 76
size, 17
I
E Input, 17
Error, 19 binary, 45
Iterative method, 39
heavy ball method, 88
F Jacobi method, 87
Function one-step, 86
activation, 60, 69 two-step, 88
antisymmetric, 3
composite, 57
continuous, 104 K
convex, 34 Kronecker delta, 77
© The Editor(s) (if applicable) and The Author(s), under exclusive license to 117
Springer Nature Switzerland AG 2026
X.-S. Wang, C. Wang, Machine Learning in Data Processing, Forum for
Interdisciplinary Mathematics, [Link]
118 Index
L l 2 ., 99
Layer l p ., 108
hidden, 60, 63 Frobenius, 99, 109
input, 60, 63 matrix, 109
output, 60, 63 vector, 75, 108
Least absolute shrinkage and selection operator Normal distribution, 19, 31
(LASSO), 34 multivariate, 19
Least squares approximation, 20
Limit point, 103
Linear correlation, 25 O
Linear system, 27, 83, 86 Objective function, 20
Logic gate, 45 Observation, 18, 75
Optimization problem, 20, 48, 76
constrained, 77
M minimax, 87, 88
Matrix, 1 Output, 17
characteristic polynomial, 108 binary, 45
conjugate transpose, 93 Overfitting, 32
determinant, 3, 106
eigenvalue, 108
eigenvector, 108 P
factorization, 94 Parameter, 18, 75
Hermitian, 106 feasible, 76
Hessian, 13 learning rate, 39, 50
identity, 2, 106 normalized feasible, 76
invertible/nonsingular, 2, 106 regularization, 41
Jacobian, 13 tuning/hyperparameter, 33
minor, 1 Prediction, 18, 46
multiplication, 106 Principal component analysis (PCA), 95
nonnegative definite/positive semidefinite, Projection, 21, 84, 96
108 Pythagorean theorem, 21, 97
normal, 106
orthogonal, 95
positive definite, 83, 108
principal component, 96 R
product, 2 Rayleigh quotient, 95
rank, 9 Regression
singular value, 95 linear, 17
spectral radius, 108 nonlinear, 48
symmetric, 2, 106 Ridge, 32
trace, 2, 107 Regularization, 31
transpose, 2, 106 l 1 ., 40
unitary, 93, 106 l 2 ., 32, 40
Maximum likelihood estimation, 19 Residual, 84
Mean, 19, 31
S
N Sample variance, 24
Neural network Schur decomposition, 93
deep, 63 Set
depth, 63 closed, 103
shallow, 60 compact, 104
Norm feasible, 75
l 1 ., 34 normalized feasible, 76
Index 119