Professional Documents
Culture Documents
DimensionalityReduction Pca
DimensionalityReduction Pca
| | |
X x1 x2 x n
| | |
-3-
Examples of PCA Projections
PCA projections
2D 1D
3D 2D
-4-
Problem Definition Quiz!
Input Output
A dataset X of n d-dim A unity vector u such
points which are zero that the square sum of
justified: the dataset’s projection
Dataset : X x1 , x 2 ,..., x n onto u is maximized.
n
Zero justified : x i 0
i 1
5 -5-
Projection
Angle between vectors Projection of x onto u
x u T
xT u
cos x cos xT u if u 1
Quiz! x u u
u
x
x cos xT u if u 1
6 -6-
Eigenvalue & Eigenvector
Ax x or A I x 0
x is non-zero A I is singular A I 0
-7-
Demo of Eigenvectors and Eigenvalue
Try “eigshow” in MATLAB to plot trajectories
of a linear transform in 2D
Cleve’s comments
-8-
Mathematical Formulation
Dataset representation: Square sum:
X is d by n, with n>d 2
J u p pT p XT u X u u
T T T
XXT u
| | |
X x1 x2 x n
| | |
Objective function with
a constraint on u:
Projection of each
max J u uT XXT u, s.t. uT u 1
column of X onto u: u
x1T u
~
max J u, uT XXT u 1 uT u
u ,
T Lagrange multiplier
x u
p 2 XT u
T Lagrange Multipliers | Geometric Meaning & Full Example
x n u
9 -9-
Optimization of the Obj. Function
Set the gradient to zero: If we arrange
J u, u XX u 1 u u 0
~ T T T eigenvalues such that:
u u
10 -10-
Facts about Symmetric Matrices
A symmetric matrix have orthogonal eigenvectors
corresponding to different eigenvalues
Proof: Quiz!
1
Ax x
1 1
1 2x T
Ax x T
1 2 2 x T
2 1 x2
x
T T
T
Ax
2 x
2 2 x
1 A x2 Ax 1 x2 T
1 1 x2
x
2 x1T x2 1 x1T x2 2 1 x1T x2 0 x1T x2 0.
11 -11-
Conversion
Conversion between orthonormal bases
1, if i j
ui u j = uTi u j
0, otherwise
| | |
U u1 u2 ud UT U I U1 UT
| | |
y
| | | 1
y
x y1u1 y2 u2 yd ud u1 u2 ud 2 Uy
| |
|
yd
y U1x = UT x
Projection of x onto u1, u2, …
12 -12-
Steps for PCA
1. Find the sample mean: 1 n
μ xi
n i 1
2. Compute the covariance matrix:
1 1 n
C XX (x i μ)(x i μ)T
T
n n i 1
3. Find the eigenvalues of nC and arrange
them into descending order,
1 2 d
| | |
U u1 u 2 u d
| | |
13 -13-
Quiz: Prove that both LS and TLS lines
i 1
Quiz!
Line : ax by c 0 Hint : The shortest distance between
a point x0 , y0 and a line ax by c 0
n
Fitting error : J a, b, c
axi byi c
2
ax0 by0 c
i 1 a 2 b2 is .
a b
2 2
-14-
PCA for TLS
Problem for ordinary LS (least squares)
Not robust if the fitting line has a large slope
PCA can be used for TLS (total least squares)
Concept of PCA for TLS
-15-
Three Steps of PCA for TLS
2D 3D Quiz!
-16-
Tidbits
Comparison of methods for dim. reduction
PCA: For unlabeled data Unsupervised leaning
LDA (linear discriminant analysis): For
classifying labeled data Supervised learning
If d>>n, then we need to have a workaround
for computing the eigenvectors
17 -17-
Example of PCA
IRIS dataset projection
18 -18-
Weakness of PCA for Classification
Not designed for classification problem (with labeled
training data)
19 -19-
Linear Discriminant Analysis
LDA projection onto directions that can best separate data
of different classes.
20 -20-
Exercise 1
-21-
Exercise 2
-22-
Exercise 3
-23-
Exercise 4
-24-