I am trying to do PCA using the SVD method manually and compare the results with the results computed by PCA on sklearn.
Let's say that our matrix is A = [[3 0],[0 -2]]
Following the SVD method, I first compute:
1) A^T A = [[9 0], [0 4]] with A^T the transpose matrix of A
2) Then I compute the eigen value given the fact that σ = sqrt(λ) det(A^T A - λ I ) = 0 with I the identity matrix. I found σ1 = 3 and σ2 = 2
3) I can compute now Σ whose value are the σ values.
4) Now I compute the V matrix. To do that I solve : A^T A v = λ v for each λ value. I got : V = [[1 0], [0 1]]
5) To compute U, we can use the formula ui = Avi/σi
U = [ [1 0], [0 -1]]
Then I tried to compute the projection of A (the new k features with k = 2 in this case) using the formula Y = U^T A but the results I got are different from what I got on the pca from sklearn.
My results : Y = [[3 0 ],[0 2]]
sklearn results : [[ 1.80277564e+00 -1.11022302e-16] [-1.80277564e+00 1.11022302e-16]]
Does anyone know where is my mistake ? Does the pca give us different results depending of the method used ?