Lect5 Reg
Lect5 Reg
• Linear regression
• Loss function
• Ridge regression
• Basis functions
Regression
y
Φ : x → Φ(x) R1 → R 3
Φ is an N × M design matrix
e.g. for polynomial regression with basis functions up to x2
⎡ ⎤
1 x1 2
x1 ⎛
⎢ ⎥ ⎞
⎢ 1
⎢ x2 x2 ⎥ w
2 ⎥⎜ 0 ⎟
Φw =⎢
⎢ . . ⎥⎥ ⎝ w1 ⎠
⎢
⎣ . . ⎥⎦ w2
1 xN 2
xN
N
1 X λ
e
E(w) = {f (xi, w) − yi}2 + kwk2
2 i=1 2
N ³ ´2
1 X λ
= yi − w>Φ(xi) + kwk2
2 i=1 2
1 λ
= (y − Φw)2 + kwk2
2 2
• As λ → ∞, w → 1 >
λΦ y → 0
³ ´−1
w >
= Φ Φ + λI Φ> y
0.5
y
-0.5
M
X
f (x, w) = wj xj = w> Φ(x) Φ : x → Φ(x) R → RM +1
j=0
w is a M+1
dimensional vector
N = 9 samples, M = 7
1.5 1.5
Sample points Sample points
Ideal fit Ideal fit
1 lambda = 100 1 lambda = 0.001
0.5 0.5
0 0
y
y
-0.5 -0.5
-1 -1
-1.5 -1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x x
1.5 1.5
Sample points Sample points
Ideal fit Ideal fit
1 lambda = 1e-010 1 lambda = 1e-015
0.5 0.5
0 0
y
y
-0.5 -0.5
-1 -1
-1.5 -1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x x
M=3 M=5
least-squares fit least-squares fit
1.5 1.5
Sample points Sample points
Ideal fit Ideal fit
1 Least-squares solution 1 Least-squares solution
0.5 0.5
y
0
y
-0.5
-0.5
-1
-1
-1.5
-1.5 Polynomial basis functions 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Polynomial basis
x functions
15 x
400
10
300
5
200
0
100
-5
y
y
-10
-100
-15
-200
-20
-300
-25
-400
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
0
y
N
X 2
/σ2 R → RN
f (x, w) = wi e−(x−xi ) = w> Φ(x) Φ : x → Φ(x)
i=1
w is a N-vector
N = 9 samples, sigma = 0.334
1.5 1.5
Sample points Sample points
Ideal fit Ideal fit
1 lambda = 100 1 lambda = 0.001
0.5 0.5
0 0
y
y
-0.5 -0.5
-1 -1
-1.5 -1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x x
1.5 1.5
Sample points Sample points
Ideal fit Ideal fit
1 lambda = 1e-010 1 lambda = 1e-015
0.5 0.5
0 0
y
-0.5 -0.5
-1 -1
-1.5 -1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x x
6 1.5
Ideal fit Sample points
Validation Ideal fit
5 Training 1 Validation set fit
Min error
4 0.5
error norm
3 0
y
2 -0.5
1 -1
0 -1.5
-10 -5 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
10 10 10
log λ x
Sigma = 0.334 Sigma = 0.1
1.5
1.5
Sample points
Sample points
Ideal fit
Ideal fit
1 Validation set fit
1 Validation set fit
0.5
0.5
y
0
y
-0.5
-0.5
-1
-1
-1.5
-1.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
x
Gaussian basis functions
Gaussian basis functions
0.8
2000
0.6
1500
1000
0.4
500 0.2
0 0
y
y
-500 -0.2
-1000 -0.4
-1500 -0.6
-2000 -0.8
a = (K + λI)−1 y Exercise
Applications:
• motion capture, resynthesis
• human-computer interaction
• action recognition
• visual surveillance
y = Ak(x)
where
• k(x) = (k(x, x1), k(x, x2), . . . , k(x, xN )) > is a vector of scalar ba-
sis functions.
Learn A from training data {xi, yi} by optimizing the cost function
N
X
min ||yi − Ak(xi)||2 + λtrace(A>A)
A
i
Training and test data
(y)
1. Preprocessing
a) Background subtraction
b) Shadow removal for
silhouette extraction
Tracking a real motion sequence
2. Regression
Background reading