Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Low-Rank Approximation with SVD

Hello! Let's dive into the final lesson of our module on Eigenanalysis and Matrix Decompositions.

Introduction

In our previous lesson, we formally defined the Singular Value Decomposition (SVD), , and saw that any matrix can be expressed as a sum of rank-one matrices, known as its dyadic form:

where is the rank of , and the singular values are ordered from largest to smallest. This structure is not just a mathematical curiosity; it's the key to one of the most powerful applications of SVD.

Today's learning outcome is to use SVD to perform low-rank approximation of a data matrix. We will see that by simply truncating this sum—keeping only the terms with the largest singular values—we can create a lower-rank matrix that is the best possible approximation of the original. This concept is fundamental to applications like image compression, recommender systems, and noise reduction in data.

The Construction of a Low-Rank Approximation

The dyadic form of the SVD gives us a way to build the matrix piece by piece. The first term, , represents the most significant rank-one component of the matrix. Each subsequent term adds a layer of finer detail. This suggests that if we want to capture the "essence" of the matrix while discarding less important information (or noise), we can just keep the first terms of the sum, where .

We define the best rank-k approximation of , denoted , as:

This new matrix has, by construction, a rank of .

Another way to think about this is in terms of the full factorization. To get , we take the matrix and set all singular values after the k-th one to zero. Let's call this new matrix . Then:

The following image provides a clear visual summary of this process.

Low-rank Approximation via SVD
This diagram illustrates the construction of a rank-k approximation, A_k. It can be viewed either as a truncated sum of rank-one matrices (right side) or by modifying the Σ matrix to keep only the first k singular values (left side).

But what do we mean by the "best" approximation? To answer this, we need a way to measure the size of the error, which is the difference matrix . This brings us to the concept of matrix norms.

Measuring Error with Matrix Norms

Just as a vector norm measures the length of a vector, a matrix norm measures the "size" or "magnitude" of a matrix. The idea of the "best" approximation is formalized as finding a rank- matrix that minimizes the norm of the error, .

While there are many matrix norms, the Eckart-Young theorem holds for two particularly important ones that are defined using singular values.

IFT 6760A - Lecture 5 SVD, Matrix Norms and Low Rank Approximation Theorem

To formalize our discussion, we need precise definitions for the norms we will use to measure the approximation error. Please review the following resource, which defines the matrix 2-norm (also called the spectral norm) and the Frobenius norm.

Please read Section 3, 'Matrix Norms' (pages 2-4). Focus on Definition 3 (Matrix p-norm, for p=2) and Definition 4 (Frobenius Norm). Crucially, notice Property 5, which states that orthogonal matrices preserve these norms, and Property 6, which shows that the 2-norm of a matrix is simply its largest singular value, σ₁.

From the reading, the two key norms are:

  1. The Spectral Norm (2-norm): , the largest singular value of . It measures the maximum "stretching" effect the matrix has on any unit vector.
  2. The Frobenius Norm: . This is like treating the matrix as one long vector and calculating its standard Euclidean length. A key property is that .

With these tools, we can now state the central theorem of this lesson.

The Eckart-Young-Mirsky Theorem: The Optimality of SVD

The main result that makes SVD so useful for approximation is the Eckart-Young-Mirsky Theorem. It states that the matrix we constructed by truncating the SVD is not just a good approximation of , but it is the best possible rank- approximation.

7. Eckart-Young: The Closest Rank k Matrix to A

Let's begin with an intuitive introduction to this powerful theorem from Professor Gilbert Strang. He explains why the SVD provides the perfect components for this approximation task.

Please watch from the beginning to 04:00. Professor Strang introduces the main idea of the Eckart-Young theorem and emphasizes that the SVD naturally provides the components for the best rank-k approximation.

Now, for the formal statement and proof. The theorem provides an exact formula for the minimum possible error.

Theorem (Eckart-Young-Mirsky):
Let be an matrix of rank , and let be its rank- approximation from SVD, with . Then for any matrix of rank at most :

  1. Spectral Norm:
  2. Frobenius Norm:

This theorem is profound: it tells us that no other rank- matrix can get closer to than the one we build from its SVD. The error of our approximation is precisely determined by the singular values we chose to discard.

Since you've requested mathematical rigor, we will now examine the proof of this theorem.

IFT 6760A - Lecture 5 SVD, Matrix Norms and Low Rank Approximation Theorem

The proof of the Eckart-Young-Mirsky theorem is a beautiful application of the linear algebra concepts we have been studying. The following resource provides a complete and rigorous proof for both norms.

Please read Section 4, 'Low Rank Approximation' (pages 4-6). Follow the proof for the 2-norm carefully. Note how it uses the Rank-Nullity Theorem to guarantee the existence of a special vector in two different subspaces, which leads to the result. The proof for the Frobenius norm relies on a result called Weyl's inequality, which you can take as given.

Test your understanding!

A matrix has a rank of 5, and its singular values are .

You want to find the best rank-2 approximation, .

  1. What is the error of this approximation measured in the spectral norm, ?
  2. What is the error measured in the Frobenius norm, ?
Show answer

According to the Eckart-Young-Mirsky theorem:

  1. The error in the spectral norm is the first discarded singular value. Since we are keeping the first two (), the first one we discard is .
    Therefore, .

  2. The error in the Frobenius norm is the square root of the sum of squares of all discarded singular values.

How to Choose the Rank k?

The theorem provides the optimal approximation for a given rank , but it doesn't tell us how to choose . This choice involves a trade-off:

  • A small gives high compression/dimensionality reduction but a less accurate approximation.
  • A large gives a very accurate approximation but less compression.

In practice, a common heuristic is to choose such that a certain percentage (e.g., 90%) of the "energy" of the matrix is retained. The total energy is defined as the squared Frobenius norm, .

The fraction of energy retained by a rank- approximation is:

One can then plot this cumulative energy against and choose a at the "elbow" of the curve, where adding more components yields diminishing returns.

Lecture 49 — SVD Gives the Best Low Rank Approximation (Advanced) | Stanford

This practical consideration is crucial when applying SVD. This short video explains the concept of choosing k based on retaining a desired percentage of the data's 'energy'.

Watch the segment from 05:14 to 06:40. The presenter explains how to calculate the fraction of total energy preserved and uses it as a rule of thumb for selecting the number of dimensions, k.

This idea of retaining variance should be familiar from our discussion on PCA. Indeed, for a centered data matrix, the squared singular values from SVD are directly proportional to the eigenvalues of the covariance matrix used in PCA. SVD provides a more direct and numerically stable way to achieve the same goal.

Conclusion

This lesson completes our deep dive into SVD and its role in creating optimal low-rank approximations. This is a cornerstone of modern data analysis, enabling efficient handling and interpretation of large-scale data.

Key Takeaways:

  • The SVD of a matrix can be used to construct a rank- approximation by summing the first terms of its dyadic expansion.
  • The Eckart-Young-Mirsky Theorem guarantees that is the best possible rank- approximation to , minimizing the error in both the spectral and Frobenius norms.
  • The approximation error is determined entirely by the singular values that are discarded: and .
  • The choice of rank is a practical decision based on the desired balance between accuracy and compression, often guided by the concept of "retained energy."

Preview of the Next Module:
We have now concluded our module on Eigenanalysis and Matrix Decompositions. You have built a solid foundation in the linear algebra that underpins many machine learning algorithms.

Our next module, Multivariate Calculus for Machine Learning, will equip us with a new set of essential tools. We will move from the world of linear transformations to the world of functions and optimization. You will learn to compute partial derivatives, gradients, and Hessian matrices. These concepts are the language of optimization, allowing us to find the minimum of a function—for instance, to find the model parameters that minimize a cost function. This is the mathematical engine that drives the training of almost every machine learning model.

Can't find a good explanation? Sign up and we'll make it for you

Sign up