Where We Are
Eigenvector PCA forms . But Chapter 040 introduced a decomposition that acts directly on a matrix:
The connection is exact.
1. Square the data matrix conceptually
Starting with
consider
Substitute the SVD:
Because ,
But covariance is proportional to :
Therefore the columns of are the covariance eigenvectors—the PCA directions.
The covariance eigenvalues are
2. One idea, two viewpoints
Eigen route:
X → covariance XᵀX → eigenvectors
SVD route:
X → UΣVᵀ → right singular vectors V
Both produce the same principal subspace (up to sign and degeneracies).
3. Why SVD is often preferred
Explicitly forming can worsen numerical conditioning and may be inefficient. Practical PCA implementations often use SVD or related solvers directly.
4. Compression and reconstruction
Keep the first right singular vectors .
and approximately reconstruct
This is not arbitrary compression. Among rank- linear approximations, truncated SVD gives the smallest Frobenius reconstruction error (Eckart–Young theorem).
5. Shape Check
If X is [N,D] and we keep k components:
V_k [D,k]
Z=X V_k [N,k]
X_hat [N,D]
6. Small PyTorch connection
Xc = X - X.mean(0, keepdim=True)
U, S, Vh = torch.linalg.svd(Xc, full_matrices=False)
Vk = Vh[:k].T
Z = Xc @ Vk
Before running, trace every shape.
What to Remember
- PCA covariance eigenvectors are the right singular vectors of centered data.
- PCA eigenvalues equal squared singular values divided by .
- SVD gives a numerically natural path to PCA.
- Truncation gives optimal linear low-rank reconstruction.
Next → t-SNE and UMAP: PCA preserves linear directions. What if the interesting structure bends and curves?