Lecture 20 - Principal Component Analysis (Application)

The goal for this application is:

Find the k-dimensional subspace that minimizes the average square distance between the points x→i and the subspace

In reference to the picture above, we want to equivalently maximize the average squared distance of the projection.

centered data

Data is centered if ∑i=1nx→i=0→

If the data is not centered, you can just subtract the average from each x→i and then get a centered data. Specifically:

x―=1n∑i=1nx→i

Then let y→i=x→i−x―. This new data y→i is now centered.

How do we Find the Subspace?

We really want to find some orthonormal basis for the subspace U. Namely a v1,...,vk such that it maximizes the projections from U onto Rd, or:

1n∑i=1n∑j=1k⟨x→i,v→j⟩2

is the value we want to maximize.

Define the matrix X such that the rows of the matrix are the data:

X=[…x→1……x→2……x→3…⋮⋮⋮]

Given any unit vector u→ then:

Xu→=[⟨x→1,u→⟩⟨x→2,u→⟩⋮⟨x→n,u→⟩]=‖Xu→‖2

We want to maximize ‖Xu→‖2. Notice:

‖Xu→‖2=⟨Xu,Xu⟩=(Xu)TXu=uTXTX⏟Symmetric, Set to Au

Thus we want to diagonalize A, A=QDQT:

We can use SVD to determine that X=USVT:

A=XTX=(USVT)TUSVT=(VSTUT)(USVT)=VSTSVT

Recall that STS was a diagonal matrix, so S contains the singular values for A, with right singular vectors from VT. So the right singular vectors are eigenvalues of XTX.

Recall that X=USVT. So then since V is a unitary matrix:

XV=US[⟨x1,v1⟩⟨x1,v2⟩…⟨x1,vd⟩⋮⋮⋱⋮⟨xn,v1⟩⟨xn,v2⟩…⟨xn,vd⟩]=

What we can do is take any row and chop it off before the d-th entry to obtain the projection of one xi onto the subspace we found:

x→i=∑j=1k⟨xi,vj⟩