NOTE

This is part of the 10th homework, titled Dimensionality Reduction 1, for the course Machine Learning (IN2064) in the Winter Semester 2024/25 at TUM.

Problem 3

Let the matrix represent data points of dimension (samples stored as rows). We applied PCA to . By using the top principal components, we transformed/projected into . We computed that preserves 70% of the variance of the original data .

Suppose now we apply PCA on the following matrices:

  • a) where , with and is the identity matrix
  • b) where and
  • c) where is a diagonal matrix
  • d) where is a diagonal matrix
  • e) where and is an -dimensional column vector of all ones
  • f) where and

and obtain the projected data using the principal components corresponding to the top largest eigenvalues of the respective . What fraction of variance of each will be preserved by each respective ? Justify your answer. The answer “cannot tell without additional information” is also valid if you provide a justification.

Solution:

a) where , with and is the identity matrix

The goal of the PCA is to decompose the data into where is the matrix of eigenvectors and is diagonal matrix of the corresponding eigenvalues ordered in a decreasing order after taking their absolute value. As such PCA decomposition of would go as follows:

Now, when we do dimensionality reduction by leaving zeroing all but first columns of . Recall, that the eigenvalues correspond to the variance on a given dimension. Given that the sum of top eigenvalues of was equal to the 70% of the all eigenvalues, then after multiplication by a constant this property will still hold. As, such we can conclude that will preserve also 70% of the variance.

b) where and

The description of the matrix tells as that is an orthogonal matrix. We know that, orthogonal linear maps preserve the inner product of vectors. So they do not change the eigenvalues, as no scaling happens. Therefore, again will preserve the same proportion of variance as does which in the case of this question is 70%.

c) where is a diagonal matrix

The linear map scales every dimension of the input space by five and inverts the evenly indexed ones. This has no impact on the magnitude of eigenvalues other than the one discussed in the point a) and as such the same proportion of variance is preserved as in the case of .

d) where is a diagonal matrix

Here linear map scales each dimension by a different factor, this in turn scales eigenvalues by different factors too and thus we cannot tell what proportion of variance will be ultimately preserved.

e) where and is an -dimensional column vector of all ones

The addition of doesn’t impact the PCA decomposition as the first step of the PCA method is to center the data.

f) where and

Here, we are multiplying by a matrix A which is of rank 5, this results in a rank of being at most 5. Thus it will have at most 5 eigenvectors and therefore if we decrease dimensionality of the data to 5 then we can’t lose variance, i.e. we are preservering 100% of it.

Problem 4

You are given data points: , represented with the matrix .

Hint: In this task the results of all (final and intermediate) computations happen to be integers.

  • a) Perform principal component analysis (PCA) of the data , i.e. find the principal components and their associated variances in the transformed coordinate system. Show your work.
  • b) Project the data to two dimensions, i.e. write down the transformed data matrix using the top-2 principal components you computed in (a). What fraction of variance of is preserved by ?
  • c) Let be a new data point. Specify the vector such that performing PCA on the data including the new data point leads to exactly the same principal components as in (a).

Solution

a) Perform principal component analysis (PCA) of the data , i.e. find the principal components and their associated variances in the transformed coordinate system. Show your work.

Step 1: Center the data: Each row is in the matrix is a data-point. As such, we center the data by subtracting an average data-point from row:

Step 2: Compute covariance matrix: Recall covariance between two random variables is given by:

Then a covariance matrix is given as follows:

We will use the right most part of the equality, especially since we can disregard having centered the data in the step one. Thus,

Step 3: find the eigenvector as and perform the decomposition. Normally we would use the power Iteration a.k.a Von Mises iteration, however since our covariance matrix is already diagonal we get the eigenvectors and their eigenvalues for free! The eigenvalues:

and their corresponding eigenvectors:

One thing to remember when decomposing into is that the eigenvalues in the matrix have to ordered in decreasing oder with respect to their absolute values. So the final decomposition is given by:

b) Project the data to two dimensions, i.e. write down the transformed data matrix using the top-2 principal components you computed in (a). What fraction of variance of is preserved by ? The projection comes down to multiplication of the centered data with the first two columns of the of the matrix:

Now, the matrix is a covariance matrix of the new space. We can use this fact with to calculate the percentage of preserved variance:

c) Let be a new data point. Specify the vector such that performing PCA on the data including the new data point leads to exactly the same principal components as in (a).

The idea here is to choose a vector such that it doesn’t change the eigenvalues of the covariance matrix, i.e. at most it scales the values of the covariance matrix. We can do that by choosing the vector that is the mean of the all the pre-existing vectors. In our case that would be:

Then after centering it will be zeroed-out, and thus it will not impact covariance matrix other than rescaling its values as we have increased number of data-points by one so the preceding scaling factor of the covariance matrix is no longer but .