Linear Dimensionality Reduction: Principal Component Analysis (PCA), Study Guides, Projects, Research of Computer Science

Principal component analysis (pca), a technique used to find a representation of data in a lower-dimensional space while preserving most of the original information. Two ways of deriving pca: maximizing variance and minimizing reconstruction error. It also provides the algorithm for performing pca on a dataset.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/30/2009

koofers-user-w8h
koofers-user-w8h 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Machine Learning (CS 5350/CS 6350) 25 Mar 2008
Linear Dimensionality Reduction
Often we want to find a representation of data from RDin some lower-dimenaional space, RK, for KD.
For K {2,3}, this is useful for visualization. For other K, it’s useful if we believe that the data is noisy,
or not ideal for our learning algorithm (eg., kNN).
Have data matrix in XRN×D. Want to linearly project Xinto some ZRN×K. We don’t want to lose
much “information.”
Two ways of deriving PCA:
Project Xonto basis vectors of highest variance
Project Xin such a way that the reconstruction error is minimized
Imagine data was generated by an K-dimensional Gaussian and then noisified into Ddimensions (wait
until probabilistic models time)
(1) is standard, hence the name “principle component analysis” (a component is a basis vector).
First, center Xso it has mean 0.
Now, supposed we want to find a single dimension to project down on to. Represent this dimension by
a vector u, so that Z=Xu. We want to find uso that V[Z] = V[Xu] is maximized. We have to be
careful to ensure that uis a unit vector; otherwise we get trivial uninteresting solutions. This turns into an
optimization problem:
max
u:||u||=1
V[Xu] = max
u:||u||=1
1
NX
nu>xn2
= max
u:||u||=1
1
N||Xu||2
To solve this, we construct the Lagrangian by adding a multiplier for the constraint ||u||2= 1 (changing to
squared norm doesn’t change the problem); we also throw out the 1
Nbecause it is a constant. Then we take
the gradient and set it equal to zero.
L(u, λ) = ||Xu||2λ||u||21
uL= 2(X>X)u2λu= 0
(X>X)u=λu
So now all we need to do is solve the above for u. Note that this has the form Au=λuwhere Ais defined as
X>X. The solution to this problem is a vector uthat is an eigenvector of Aand can be computed “easily”
(use eig or eigs in Matlab/Octave).
When you get eigenvectors/eigenvalues of a matrix Aof size D×D, you will get D-many pairs (uii).
The λs are measures of the variance along the corresponding u, so we want to select the uiwith largest
corresponding λi.
In general, to project onto K > 1 dimensions, instead of choosing the single eigenvector with largest eigen-
value, we take the top K(they are guaranteed to be orthogonal).
1
pf2

Partial preview of the text

Download Linear Dimensionality Reduction: Principal Component Analysis (PCA) and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Machine Learning (CS 5350/CS 6350) 25 Mar 2008

Linear Dimensionality Reduction

Often we want to find a representation of data from RD^ in some lower-dimenaional space, RK^ , for K  D. For K ∈ { 2 , 3 }, this is useful for visualization. For other K, it’s useful if we believe that the data is noisy, or not ideal for our learning algorithm (eg., kNN).

Have data matrix in X ∈ RN^ ×D^. Want to linearly project X into some Z ∈ RN^ ×K^. We don’t want to lose much “information.”

Two ways of deriving PCA:

  • Project X onto basis vectors of highest variance
  • Project X in such a way that the reconstruction error is minimized
  • Imagine data was generated by an K-dimensional Gaussian and then noisified into D dimensions (wait until probabilistic models time)

(1) is standard, hence the name “principle component analysis” (a component is a basis vector).

First, center X so it has mean 0.

Now, supposed we want to find a single dimension to project down on to. Represent this dimension by a vector u, so that Z = Xu. We want to find u so that V[Z] = V[Xu] is maximized. We have to be careful to ensure that u is a unit vector; otherwise we get trivial uninteresting solutions. This turns into an optimization problem:

max u:||u||=

V[Xu] = max u:||u||=

N

n

u>xn

= max u:||u||=

N

||Xu||^2

To solve this, we construct the Lagrangian by adding a multiplier for the constraint ||u||^2 = 1 (changing to squared norm doesn’t change the problem); we also throw out the (^) N^1 because it is a constant. Then we take the gradient and set it equal to zero.

L(u, λ) = ||Xu||^2 − λ

||u||^2 − 1

∇uL = 2(X>X)u − 2 λu = 0 ⇐⇒(X>X)u = λu

So now all we need to do is solve the above for u. Note that this has the form Au = λu where A is defined as X>X. The solution to this problem is a vector u that is an eigenvector of A and can be computed “easily” (use eig or eigs in Matlab/Octave).

When you get eigenvectors/eigenvalues of a matrix A of size D × D, you will get D-many pairs (ui, λi). The λs are measures of the variance along the corresponding u, so we want to select the ui with largest corresponding λi.

In general, to project onto K > 1 dimensions, instead of choosing the single eigenvector with largest eigen- value, we take the top K (they are guaranteed to be orthogonal).

Machine Learning (CS 5350/CS 6350) 2

The algorithm looks like:

  • Center the data so X has mean zero
  • Compute A = X>X
  • Compute 〈ui, λi〉Ki=1 the top K eigenvectors/values of A
  • Project Z = XU, where U is the D × K matrix comprised of the top K eigenvectors

An alternative way of thinking about PCA is as minimizing a reconstruction error. If we have a data point xn and project it with xnU 7 → zn, then we can “unproject” by znU>^7 → ˜xn. We can look at the reconstruction error ||xn − ˜xn||^2 and try to minimize this over U, where we constrain U to be orthonormal (i.e., orthogonal and unit vectors). The one-dimensional case is easier to see:

min u

n

||xn − x˜n||^2 = min u

n

∣xn − xnuu>

∣^2

= min u

n

||xn||^2 − (xn>u)^2

= (constant) + min u

n

(xn>u)^2

= (constant) − max u

n

(xn>u)^2

= (constant) − max u ||Xu||^2

Here, the last line is exactly (modulo the constant) the same optimization we had in the variance case.

The intuition behind PCA is that we’re trying to find (non-axis-aligned) basis vectors along which X has highest variance. Doing so turns into an eigenvalue problem which we know how to solve. The second intuition is that we’re trying to minimize reconstruction error (measured in terms of squared error) and this reverts to the same thing.