Lecture 6 dimensionality reduction

Lecture 5- Dimensionality Reduction

THe first latent dimension is the direction in which the points have the highest variance. THe second is the dimension orthogonal to the first, in which the points show the 2nd greatest variance.

Linear Algebra

The Rank of a matrix measures dimensionality.

##$X^TX$ For a matrix $X$, $X^TX$ (the Gram matrix, also known as the covariance matrix) is a square matrix whose diagonal elements are the sums of squares of of elements in $x$, and is positive semi-definite.

PCA

PCA involves converting a set of observations into a set of values of linearly uncorrelated principal components. The transformation is defined in such a way that the principal components are ordered in terms of variance, and all principal components are orthogonal to each other.

For a data matrix $M$, PCA is normally computed by computing the matrx of eigenvectors $W$ of $M^TM$ (the Gram matrix or correlation matrix). The full principal components decomposition of $M$ is then $T=MW$ (you can drop some columns if you don’t want the whole decomposition). The matrix $W$ of eigenvectors of the correlation matrix $M^TM$ can be thought of as a rigid rotation in high dimensional space. When you apply this transformation to the original data, the axis corresponding to the principal eigenvector is the one along which the points are most spread out.

SVD:

Screenshot 2019-10-23 at 9.55.04 PM.png

U is the left singular vectors $\Sigma$ is the right singular vectors V is the right singular vectors

Properties:

It is always possible to decompose a real matrix A into $A = U \Sigma V^T$ where

Screenshot 2019-10-23 at 10.02.24 PM.png

SVD Decomposes into:

If you multiply the AVD decomposition for particular axes, that is the projection of the data onto that axis.

Computing SVD

First we need a method for finding th principal eigenvalue and eigenvector of a symmetric matrix. Method (Power Iteration - We never use this in practice as there are much more advanced methods, but this is a good basic method):

  1. Start with any ‘guess eigenvector’ $x_0$
  2. Construct $x_{k+1} = \frac{M_{x_k}}{   M_{X_k}   _F}$ for k=0,1,… and stop when converge
  3. Once you have the princple eigenvector $x$, get its eigenvalue $\lambda$ by $\lambda = x^TMx$.
  4. Find more eigenvalues and vectors by continuing on , where $M*$ is the matrix after removing the factor of x.

This algorithm is very distributable. You only need a couple of iterations.

Suppose $A=U\Sigma V^T$ $A^TA = V \Sigma^2V^T$ since $U^TU$ is an identity matrix by orthonormality. $(A^TA)V=V\Sigma^2$.

Thus, we can find $V$ and $\Sigma$ by finding the eigenpairs for $A^TA$. We can find $U$ and $\Sigma$ by finding the eigenpairs for $AA^T$.

Time Complexity when computing the full SVD using specialized methods: $O(nm^2)$ or $O(n^2m)$ whichever is less. But less work if we just wnat singular values, or if we want the first k singular vectors, or if the matrix is sparse.

Using SVD

Q: Find users that like movie ‘Matrix’ but havent watched it. A: Map query into the ‘concept space’ for Matrix.

Advantages of SVD: Optimal low-rank approximation (in Frobenius norm) Drawbacks of SVD:

CUR Decomposition

CUR is a provably good approximation to SVD (3). It performs much better than SVD space and time-wise on sparse data (4). The tradeoff is introducing some small error. Motivation: It is common for the matrix A we wish to decompose to be very sparse. But U and V from an SVD decomposition will not be sparse. CUR decomposition solves this problem by using only (randomly chosen) rows and columns of A.

Goal: Express A as a product of matrices C, U, R. Make $||A - C\cdot U\cdot R||_F$ small Matrix U is not diagonal, it is the dense pseudo-inverse of the intersection of C and R. Constraints on C and R:

Screenshot 2019-10-23 at 10.54.49 PM.pngScreenshot 2019-10-23 at 10.56.31 PM.png

Let $W$ be the ‘intersection of sampled columns C and rows R. Def: $W+$ is the pseudoinverse Let SVD of $W = XZY^T$ Then: $W^+ = YZ+X^T$ where $Z+$ is the reciprocals of non-zero singular values Z^+{ii} = 1/Z{ii}. The pseudinvest is as lcose to the real inverse as you can get (2)

How to sample the rows and columns? We must decrease the exected error between A and its decomposition, so we much pick rows and columns in a non-uniform nammer. We pick rows and coluymns wiht probability proportional to the square of its Frobenium norm (its ‘importance’)

CUR Ago:

Screenshot 2019-10-23 at 11.07.32 PM.png

What CUR Computes: Screenshot 2019-10-23 at 11.13.57 PM.png

Rought untuition: CUR is more likely to pick poiunts away from the origin. Assuming smooth data with no outliers these are the directions of maximum variation.

CUR Pros:

CUR Cons

Summary

Screenshot 2019-10-23 at 11.14.26 PM.png

(1)

Screenshot 2019-10-23 at 10.52.18 PM.png

(2) Note about the pseudoinverse:

(3) CUR is a O(k log k) approximation to SVD, where k is the rank of A

Screenshot 2019-10-23 at 11.10.17 PM.png

(4)CUR Much more space and time efficient than SVD for very sparse matrices.

Screenshot 2019-10-23 at 11.16.01 PM.png