In the accompanying notebook, the Olivetti faces dataset is loaded. The data matrix is…
- User
In the accompanying notebook, the Olivetti faces dataset is loaded. The data matrix is here defined such that every row (observation) reflects a picture of a person. Implement the PCA algorithm as stated by the pseudocode on the slides. You can use the sklearn function for computing the truncated SVD or you can compute a full SVD with scipy/numpy and then truncate it manually. As discussed in the lecture, PCA is based on a low-rank matrix factorization D−1μF⊤=C≈YX⊤ where XX indicates the directions of maximum variance, i.e., the PCs. YY indicates the low-dimensional representations of the data points. Note, that when we want to reconstruct the data matrix based on the low-rank approximation, we have to add the mean μFμF to the matrix product. 1a You can plot the principal components as images, just like you would do it with the data points. Match the principal components with the faces that they represent. Drag one image to each PC. 1b Compute a PCA of dimension r=3r=3. What are the coordinates of the low-dimensional representation of the 5th datapoint (having Python index 4)? 1c We generate now a face by means of a PCA with a rank of r=50r=50. Which of the following pictures represents the face that is generated by using as coordinates of the low-dimensional representation the vector (0.5,…,0.5,−0.5,…,−0.5)∈{−0.5}^50
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.