Skip to content

Commit f9dd545

Browse files
authored
Merge pull request #1 from Machine-Learning-Foundations/suggestions
fixed some typos and added empty function so nox tests work
2 parents 9fe78c3 + ac593f7 commit f9dd545

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ Now we will implement the functions to perform a PCA transform and an inverse tr
2424
8. Sort eigenvalues in descending order and eigenvectors by their descending eigenvalues.
2525
9. Return sorted eigenvalues, eigenvectors, centered data and the mean vector.
2626

27-
Next, implement the function `pca_inverse_transform`, which reconstructs the data using the top $n_comp$ principal components following these steps:
27+
Next, implement the function `pca_inverse_transform`, which reconstructs the data using the top $n_{comp}$ principal components following these steps:
2828

29-
10. Select the first $n_comp$ components from the given eigenvectors.
29+
10. Select the first $n_{comp}$ components from the given eigenvectors.
3030
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.
3131
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:
3535

3636
14. Calculate the total variance by summing up all the eigenvalues.
37-
15. Compute the cumulative explained variance by summing the first 'n_comp' eigenvalues.
37+
15. Compute the cumulative explained variance by summing the first $n_{comp}$ eigenvalues.
3838
16. Determine the cumulative explained variance ratio by dividing the cumulative explained variance by the total variance. Return the result.
3939

4040
Go back to the `__main__` function and implement the following TODOs:

src/ex2_pca_svm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
from sklearn.model_selection import GridSearchCV, KFold, train_test_split
1212
from sklearn.preprocessing import StandardScaler
1313

14+
1415
# import or paste here your function cv_svm
1516
# TODO
17+
def cv_svm():
18+
pass
1619

1720

1821
def explained_var(xtrain: np.ndarray) -> np.ndarray:

0 commit comments

Comments
 (0)