Eigenvalues, Eigenvectors & Singular Value Decomposition (SVD)

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.

1. The Eigenvalue Equation

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\).

2. Singular Value Decomposition (SVD) Architecture

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.

3. Dimensionality Reduction: PCA via SVD in Python

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}%")

SVD in Collaborative Filtering Recommender Systems

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.

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. What is an eigenvector and eigenvalue intuitively?

When a square matrix A acts on most vectors, it rotates and scales them. However, for certain special vectors, matrix multiplication only scales them without changing their directional orientation. These vectors are eigenvectors (v), and the scale factor is the eigenvalue (lambda): A * v = lambda * v.

Q2. How does Singular Value Decomposition (SVD) generalize eigendecomposition?

Eigendecomposition only works on square, non-defective matrices. SVD generalizes this concept to ANY rectangular m x n matrix A, decomposing it into three matrices: A = U * Sigma * V^T, where U and V are orthogonal matrices and Sigma contains singular values.

Q3. How does SVD power Principal Component Analysis (PCA)?

PCA identifies the directions of maximum variance in high-dimensional data. Performing SVD on a mean-centered data matrix X decomposes it such that the columns of V are the principal component directions, and the singular values in Sigma reflect the variance explained by each component.

Q4. What is Truncated SVD and where is it used?

Truncated SVD keeps only the top k singular values and vectors, setting the rest to zero. It produces the optimal low-rank approximation of a matrix (Eckart-Young-Mirsky theorem), making it the engine behind image compression, latent semantic analysis (LSA) in NLP, and recommender systems.

Q5. How much explained variance should I retain in PCA?

A common industry rule of thumb is to retain sufficient principal components to capture 90% to 95% of total cumulative explained variance, verified using a scree plot or cumulative variance curve.

Explore Related Data Science Tutorials & Next Steps

Broaden your statistical analysis, Python data wrangling, and production engineering expertise:

Linear Algebra: Vectors & Matrices

Review dot products, matrix multiplication, and vector spaces.

Feature Engineering: PCA & Selection

Apply SVD and Eigen decomposition for Principal Component Analysis (PCA).

Customer Segmentation & K-Means

Project high-dimensional customer vectors to 2D/3D for clustering.

BCA & CS University Viva Guide

Prepare oral answers for linear algebra and matrix operations in university exams.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!