When working with high-dimensional datasets containing hundreds of features, multicollinearity and the "curse of dimensionality" can degrade machine learning performance. Matrix Decompositions — specifically Eigenvalues, Eigenvectors, and Singular Value Decomposition (SVD) — allow us to compress data while preserving its essential variance.
For a square matrix \(\mathbf{A} \in \mathbb{R}^{n \times n}\), a non-zero vector \(\mathbf{v}\) is an eigenvector with corresponding scalar eigenvalue \(\lambda\) if:
\[ \mathbf{A} \mathbf{v} = \lambda \mathbf{v} \implies (\mathbf{A} - \lambda \mathbf{I})\mathbf{v} = \mathbf{0} \]To find the eigenvalues, solve the characteristic polynomial: \(\det(\mathbf{A} - \lambda \mathbf{I}) = 0\).
Real-world data matrices \(\mathbf{X}\) with \(m\) rows and \(n\) columns are almost never square. SVD factors any matrix into three constituent matrices:
\[ \mathbf{X} = \mathbf{U} \mathbf{\Sigma} \mathbf{V}^T \]| Matrix | Dimensions | Properties & Interpretation |
|---|---|---|
| \(\mathbf{U}\) | \(m \times m\) | Left singular vectors (orthonormal eigenvectors of \(\mathbf{X}\mathbf{X}^T\)). Represents row coordinate space. |
| \(\mathbf{\Sigma}\) | \(m \times n\) | Diagonal matrix of singular values \(\sigma_1 \ge \sigma_2 \ge \dots \ge 0\) (square roots of eigenvalues of \(\mathbf{X}^T\mathbf{X}\)). |
| \(\mathbf{V}^T\) | \(n \times n\) | Right singular vectors (orthonormal eigenvectors of \(\mathbf{X}^T\mathbf{X}\)). Represents the principal component axes. |
import numpy as np
from sklearn.decomposition import PCA
# Generate synthetic 4-dimensional correlated dataset
np.random.seed(42)
X = np.random.randn(100, 4) @ np.array([
[2.0, 1.5, 0.2, 0.1],
[0.0, 1.2, 0.8, 0.3],
[0.0, 0.0, 0.5, 0.1],
[0.0, 0.0, 0.0, 0.2]
])
# Fit PCA using Scikit-Learn (internally powered by fast randomized SVD)
pca = PCA(n_components=2)
X_reduced = pca.fit_transform(X)
print(f"Original Shape: {X.shape}")
print(f"Reduced Shape: {X_reduced.shape}")
print(f"Explained Variance Ratio: {pca.explained_variance_ratio_}")
print(f"Total Variance Retained: {sum(pca.explained_variance_ratio_) * 100:.2f}%")
In Netflix-prize style recommendation systems, the sparse user-movie rating matrix R is decomposed via truncated SVD. U represents user latent preference vectors, while V represents movie genre vectors. The dot product between a user vector and item vector predicts missing ratings instantly.
Broaden your statistical analysis, Python data wrangling, and production engineering expertise:
Review dot products, matrix multiplication, and vector spaces.
Apply SVD and Eigen decomposition for Principal Component Analysis (PCA).
Project high-dimensional customer vectors to 2D/3D for clustering.
Prepare oral answers for linear algebra and matrix operations in university exams.