Lecture 10a
Overview
Matrix factorization represents an N-by-D data matrix with low-rank factors, trading reconstruction fidelity for compact storage and computation. The lecture derives PCA as mean-centered, rank-R least-squares approximation using the top covariance eigenvectors, explains cumulative variance for choosing R, and shows how full and economy SVDs compute PCA efficiently; it also derives how to standardize PCA coefficients for downstream classification or regression.
Key takeaways
- PCA's optimal rank-R reconstruction uses the R eigenvectors of the centered-data covariance matrix with the largest eigenvalues, and computes sample coordinates as V_Rᵀx̃_i.
- The proportion of variance retained by PCA is the cumulative sum of the first R covariance eigenvalues divided by the sum of all eigenvalues, giving a direct way to select a compression rank.
- Applying SVD to the centered data avoids explicitly constructing Q = X̃ᵀX̃/N; covariance eigenvalues are the squared singular values divided by N.
- A truncated economy SVD can compute only the leading R singular components, avoiding unnecessary work when the desired PCA representation is much lower-dimensional than the data.
- PCA coefficients are centered but not automatically standardized; scaling each component by its inverse standard deviation is useful before regularized regression or classification.
- PCA minimizes overall squared reconstruction error, not loss of task-relevant information, so a low-variance feature useful for predicting labels may be discarded.
Chapters
- Represent an N-by-D data matrix X as a product of a tall basis matrix and a wide coefficient matrix, with chosen rank R.
- A larger R improves reconstruction and can be exact at sufficient rank, while a smaller R reduces the number of stored parameters.
- Matrix factorization is an unsupervised learning task because it uses feature data without target labels.
- Treat each sample x_i as a D-dimensional row of X and approximate it with a linear combination of the R columns of basis matrix B.
- The basis vectors are shared across all samples, while each sample has its own R-dimensional coefficient vector z_i.
- Any component of x_i outside the column space of B is lost, making the representation a form of lossy compression when R is less than D.
- PCA subtracts the sample mean from each x_i and applies linear dimensionality reduction to the centered vectors x̃_i.
- It chooses the basis and coefficients to minimize the sum of squared Euclidean reconstruction errors across samples.
- The squared-error objective enables a closed-form solution, unlike alternatives such as an L1 residual objective, which is harder to optimize.
- Form the sample covariance matrix Q from the mean-centered data; its diagonal contains feature variances and its off-diagonal entries contain cross-covariances.
- Compute the eigendecomposition of Q and use the eigenvectors associated with its R largest eigenvalues as the columns of the optimal basis V_R.
- Obtain the optimal coefficients with ẑ_i = V_Rᵀx̃_i, then reconstruct with the sample mean plus V_Rẑ_i.
- For three-dimensional data and R = 2, PCA selects the plane through the origin that minimizes the sum of squared distances from points to their projections.
- For R = 1, PCA selects a line through the origin, and each sample's coefficient is a scalar location along that line.
- Because Q is symmetric positive semidefinite, its eigenvectors are orthogonal and its eigenvalues are real and nonnegative.
- The PCA workflow is: compute the sample mean, center the N samples, form Q, and retain the R eigenvectors with largest eigenvalues.
- Project each centered D-dimensional sample into R dimensions with V_Rᵀx̃_i, then reconstruct the approximation by adding the mean back.
- The retained eigenvectors are called principal components and span the subspace onto which PCA projects the centered data.
- Proportion of variance (POV) measures reconstruction quality as 1 minus RSS divided by N times trace(Q), analogous in form to regression R².
- For PCA, POV equals the sum of the first R covariance eigenvalues divided by the sum of all eigenvalues.
- POV rises monotonically from zero at R = 0 to one when all dimensions are retained; the curve helps balance compression against reconstruction quality.
- The full singular value decomposition writes any matrix X as UΣVᵀ, including tall, wide, and square matrices.
- U and V are square orthogonal matrices, while Σ contains nonnegative singular values ordered from largest to smallest.
- Interpreted as a linear operation on a vector, the SVD decomposes the operation into a rotation, coordinate-wise scaling, and another rotation.
- In the full SVD, zero regions of rectangular Σ eliminate corresponding columns of U or V from the product, so those components do not affect X.
- The economy SVD retains only the effective components, producing U_R, a square diagonal Σ_R, and V_Rᵀ.
- Economy-SVD factors have orthonormal columns but are not generally square orthogonal matrices, which makes them more efficient for computation.
- For centered data, Q = X̃ᵀX̃/N; substituting the full SVD of X̃ cancels UᵀU and yields covariance eigenvectors from V.
- The covariance eigenvalues correspond to squared singular values divided by N.
- Computing SVD directly on X̃ avoids explicitly forming the covariance matrix, which can be costly for large data.
- The data matrix rank is at most min(N, D), but PCA typically keeps a much smaller approximation rank R for compression.
- A truncated SVD can compute only the leading R right singular vectors instead of producing every component of the economy SVD.
- Use those R vectors as the PCA basis, project centered samples into R coefficients, and add the mean back for reconstruction.
- PCA coefficients are already zero-mean because they are linear projections of mean-centered samples.
- Their sample variances are not generally one; the coefficient covariance is determined by the retained covariance eigenvalues, equivalently squared singular values divided by N.
- Scale each retained coefficient by the inverse square root of its variance, or by √N divided by its singular value, before using the coefficients with regularized regression or classification.
Transcript excerpt
0:01 Hello everyone. I'm going to re-record these notes because there's a problem with uh my audio during the um inerson class lecture. So um we're going to uh start a new unit on matrix factorization. And uh so basically matrix factoriization the problem is that you have a data matrix X and you would like to write that matrix into a product of low rank factors uh meaning a tall matrix [snorts] times a wide matrix. So the number of rows has to be the same um your original matrix and this tall matrix and the number of
0:50 columns has to be the same for your original matrix and this wide matrix. But the number of um the rank or the number of you know columns and rows here is a design factor. We're going to refer to this rank as capital R. [clears throat] And basically if you choose the rank here as the rank of this matrix or for example d um or let's say the uh the minimum of dn then this uh this approximation would be perfect but the smaller you choose this
1:41 uh rank capital r of the approximation the worse of an approxim approximation you get. However, you have fewer parameters when describing the data. So, this is sort of the tradeoff is um on one hand, you would like to represent this data matrix with as high fidelity as possible. On the other hand, you want the most efficient representation of it using these two factors. So in terms of the kind of learning problem this is this is a unsupervised learning task similar to um what we saw with uh generative machine learning since there's features uh but no targets and there's many different applications
2:31 of this problem um one of them which I
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Prof. Schniter.