Exercises
Exercises
Conceptual
Exercise 1 Conceptual
Let \(X\) be centred with \(n\) rows and \(p\) columns, and let \(X = U S V^\top\).
- Show that \(\Phi = V\) diagonalizes \(\hat\Sigma = \frac{1}{n-1}X^\top X\), and give the eigenvalues in terms of the singular values.
- Show that \(Z = US\).
- Show that the reconstruction from all components, \(Z\Phi^\top\), gives back \(X\) exactly.
Exercise 2 Conceptual
Answer with a short justification.
- The loadings \(\phi_1\) and \(-\phi_1\) describe the same component. Why.
- Two data sets differ only in the units of one column. Do they have the same principal components.
- We add a constant to every entry of one column. Do the principal components change.
- Can the proportion of variance explained by the first component be smaller than \(1/p\).
Exercise 3 Conceptual
On principal component regression.
- Explain why PCR can help when the predictors are strongly correlated.
- Explain why PCR can fail badly even when it explains 99 percent of the variance in \(X\).
- What is the relationship between PCR and ridge regression, in one sentence.
Exercise 4 Conceptual
A colleague shows you a t-SNE plot and says three things. For each one, say whether it is justified.
- These two clusters are far apart, so the two cell types are very different.
- This cluster is larger, so there are more cells of that type.
- These points are next to each other, so they are similar.
Applied
Exercise 5 Applied
PCA on the wine data.
- Load it and standardize the 13 measurements.
- Make a scree plot and decide how many components to keep.
- Make a biplot of the first two components. Which variables are correlated.
- Colour the points by the true class. Do the classes separate.
- Repeat everything without standardizing. What changes, and why.
Exercise 6 Applied
Compression and denoising on the digits data.
- Reconstruct the images from 2, 5, 10 and 30 components and plot them.
- Plot the reconstruction error against the number of components.
- Add normal noise with standard deviation 4 and repeat. At which number of components is the reconstruction closest to the clean image.
- Explain why that number is smaller than the number needed without noise.
Exercise 7 Applied · optional
Compare PCA and t-SNE on MNIST.
- Take 5000 images. Plot the first two principal components, coloured by digit.
- Run t-SNE on the same 5000 images and plot the result.
- Run t-SNE three times with different seeds. How much does the picture change.
- Run PCA to 50 components first and then t-SNE on those. Compare the result and the running time.