Skip to content

Commit 9fe78c3

Browse files
committed
fixed wrong TODOs
1 parent d24cdf8 commit 9fe78c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Navigate to `src/ex1_pca.py` and have a look at the `__main__` function :
1717

1818
Now we will implement the functions to perform a PCA transform and an inverse transform on our 2D array. First implement the function `pca_transform`:
1919

20-
4. Compute the mean vector over the features of the input matrix. The resulting mean vector should have the size $(d,1)$.
20+
4. Compute the mean vector over the features of the input matrix. The resulting mean vector should have the size $(d,1)$. (Hint: use `keepdims=True`in the function `numpy.mean` to keep the dimensions for easier subtraction.)
2121
5. Center the data by subtracting the mean from the 2D image array.
2222
6. Compute the covariance matrix of the centered data. (Hint: `numpy.cov`.)
2323
7. Perform the eigendecomposition of the covariance matrix. (Hint: `numpy.linalg.eigh`)
@@ -27,8 +27,8 @@ Now we will implement the functions to perform a PCA transform and an inverse tr
2727
Next, implement the function `pca_inverse_transform`, which reconstructs the data using the top $n_comp$ principal components following these steps:
2828

2929
10. Select the first $n_comp$ components from the given eigenvectors.
30-
11. Project the centered data onto the space defined by the selected eigenvectors by multiplying both matrices, giving us the reduced data.
31-
12. Reconstruct the data projecting it back to the original space by multiplying the reduced data with the transposed selected eigenvectors. Don't forget to add the mean vector afterwards.
30+
11. Project the centered data onto the space defined by the selected eigenvectors by multiplying the transposed selected eigenvectors and the centered data matrix, giving us the reduced data.
31+
12. Reconstruct the data projecting it back to the original space by multiplying the selected eigenvectors with the reduced data. Don't forget to add the mean vector afterwards.
3232
13. Return the reconstructed data.
3333

3434
Now, before returning to the `__main__` function, we also want to calculate the explained variance associated with our principal components. For that, implement the `expl_var` function following these steps:

0 commit comments

Comments
 (0)