Eigenvectors & Eigenvalues for Machine Learning

Big Picture

A matrix is a transformation — it takes vectors and moves, rotates, stretches, or squishes them. For almost every vector, a matrix changes its direction. But a special few vectors keep their direction and only get stretched or shrunk. Those special vectors are eigenvectors, and the amount each is stretched is its eigenvalue.

Eigenvectors reveal the "natural axes" of a transformation — the hidden structure inside a matrix. This is exactly what many ML algorithms exploit: PCA finds the directions of maximum variance, spectral clustering finds community structure, and PageRank finds the "importance" vector of a web graph.


ML_AI/images/matrix-1.png850

Part I — The Idea

1. Prerequisite: A Matrix is a Transformation

Before eigenvectors make sense, recall what multiplying a vector by a matrix does. A square matrix A takes an input vector v and produces an output vector Av — it transforms the vector.

Take the matrix A=[2001] (it doubles the x-coordinate, leaves y alone):

A[11]=[21]A[10]=[20]A[01]=[01]

Notice something:

Those last two vectors — the ones that don't rotate — are the eigenvectors of A. Everything below is about finding them.

2. What Are Eigenvectors and Eigenvalues?

Amatrixveigenvector=λeigenvalueveigenvector

To say that Av=λv means that Av and λv are collinear with the origin i.e Av and v lie on the same line through the origin.

The One Equation That Defines Everything

Av=λv

  • A — a square matrix (the transformation)
  • v — the eigenvector (a non-zero vector whose direction is preserved)
  • λ (lambda) — the eigenvalue (the scalar stretch/shrink factor)

In words: "Transforming v with A gives the same result as simply scaling v by the number λ."

The word "eigen"

"Eigen" is German for "own" or "characteristic." An eigenvector is a vector that a matrix treats as its "own" special direction — it belongs to the transformation.

2.1 Reading the Eigenvalue

The eigenvalue λ tells you exactly what happens to the eigenvector's length and orientation:

Eigenvalue λ Effect on the eigenvector
λ>1 Stretched — same direction, longer
0<λ<1 Shrunk — same direction, shorter
λ=1 Unchanged — the vector is completely fixed
λ=0 Collapsed to zero — the direction is in the matrix's null space
λ<0 Flipped — reversed direction, then scaled by |λ|

3. Geometric Intuition

Imagine placing a rubber sheet with an arrow grid on it and then stretching the sheet with your hands (the "stretch" is the matrix A).

Analogy: A Spinning Globe

Spin a globe. Every city on the surface moves — except the two points on the axis of rotation (the North and South Poles). The axis of rotation is the eigenvector: the one direction that doesn't move under the "rotation transformation." For a pure rotation the eigenvalue along that axis is λ=1 (points on the axis don't even change length).

Analogy: Squishing Dough

Press a ball of dough flat between two boards. It spreads wide (a big stretch, large λ) in the horizontal directions and gets thin (a big shrink, small λ) vertically. The horizontal and vertical directions are the eigenvectors; the amount of spread/squish in each is the eigenvalue. The eigenvectors are the "natural axes" along which the transformation acts most simply.


Part II — Computing Them

4. The Characteristic Equation

We want non-zero eigenvectors v

(1)Av=λv

Rearranging:

Avλv=0(2)(AλI)v=0

Here I is the identity matrix (we insert it so we can subtract λ (which is scalar), from a matrix).
It has a non-zero solution v only if the matrix (AλI) is singular — i.e., its determinant is zero:

det(AλI)=0

This is the characteristic equation. Solving it gives the eigenvalues λ; plugging each λ back into (AλI)v=0 gives the eigenvectors.

Why the determinant must be zero?

If (AλI) were invertible (non-zero), the only solution would be v=0 — the trivial one we don't want (the zero vector is never an eigenvector). A non-trivial solution exists precisely when the matrix squishes some direction down to nothing, which is exactly what det=0 means.

The Recipe (3 Steps)

  1. Eigenvalues: Solve det(AλI)=0 for λ.
  2. Eigenvectors: For each λ, solve (AλI)v=0 for v.
  3. (Optional) Normalize: Scale each eigenvector to length 1 (common in ML).

5. Worked Example — 2×2 Matrix (Step by Step)

Let's find the eigenvalues and eigenvectors of:

A=[4123]
Step 1 — Form AλI
AλI=[4123][λ00λ]=[4λ123λ]
Step 2 — Set the determinant to zero (characteristic equation)

For a 2×2 matrix [abcd], the determinant is adbc:

det(AλI)=(4λ)(3λ)(1)(2)=0

Expand:

124λ3λ+λ22=0λ27λ+10=0
Step 3 — Solve for the eigenvalues

Factor the quadratic:

(λ5)(λ2)=0λ1=5,λ2=2
Step 4 — Find the eigenvector for λ1=5

Substitute λ=5 into (AλI)v=0:

[451235][xy]=[1122][xy]=[00]

Both rows give the same equation: x+y=0y=x. So any vector along [11] works:

v1=[11]
Step 5 — Find the eigenvector for λ2=2

Substitute λ=2:

[421232][xy]=[2121][xy]=[00]

This gives 2x+y=0y=2x. So an eigenvector is:

v2=[12]
Step 6 — Verify Av=λv
Av1=[4123][11]=[55]=5[11]=λ1v1Av2=[4123][12]=[24]=2[12]=λ2v2

Both check out. The matrix A stretches the [11] direction by and the [12] direction by .

6. Handy Shortcuts & Properties

For an n×n matrix there are (counting multiplicity) n eigenvalues. Two identities are great for checking your work:

Property Rule Check on the example (λ=5,2)
Sum of eigenvalues =trace(A) (sum of the diagonal) 5+2=7=4+3
Product of eigenvalues =det(A) 5×2=10=(4)(3)(1)(2)

Other useful facts:

Part III — Eigendecomposition

7. Breaking a Matrix into Its Eigen-Parts

If an n×n matrix A has n independent eigenvectors, we can factor it into its eigenvalues and eigenvectors. This is eigendecomposition (or diagonalization):

A=QΛQ1

Where:

Intuition: this splits the transformation into three simple stages — rotate into the eigenvector coordinate system (Q1), stretch along each axis (Λ), then rotate back (Q). In the eigenvector coordinate system, the complicated matrix A becomes a simple set of independent stretches.


From the worked example in §5, we found:

λ1=5,v1=[11]λ2=2,v2=[12]

Step 1 — Build Q (columns = eigenvectors):

Q=[1112]

Step 2 — Build Λ (eigenvalues on diagonal):

Λ=[5002]

Step 3 — Compute Q1:
For a 2×2 matrix [abcd], the inverse is 1adbc[dbca].

det(Q)=(1)(2)(1)(1)=3Q1=13[2111]=[23131313]

Step 4 — Verify QΛQ1=A:

QΛ=[1112][5002]=[5254]QΛQ1=[5254][23131313]=[103+2353231034353+43]=[4123]=A

Bonus — Computing A3 the easy way:

A3=QΛ3Q1,Λ3=[530023]=[125008]

No repeated matrix multiplication needed — just raise each eigenvalue to the power.

Why this is powerful

Once A=QΛQ1, computing powers becomes trivial: Ak=QΛkQ1, and Λk is just each eigenvalue raised to the k. This is the backbone of analyzing repeated/iterative processes (Markov chains, PageRank, the stability of dynamical systems).

Related: Singular Value Decomposition (SVD)

Eigendecomposition only works for square matrices. SVD generalizes the idea to any m×n matrix by decomposing it into A=UΣV, where the "singular values" in Σ play the role of eigenvalue magnitudes. SVD underlies many ML tools (recommender systems, latent semantic analysis, and a numerically stable way to compute PCA).


Part IV — Applications in Machine Learning

Eigenvectors and eigenvalues are not an abstract curiosity — they power some of the most-used algorithms in ML. The recurring theme: find the directions that matter most.

8. Principal Component Analysis (PCA) — The Flagship Use

This is the single most important application. PCA reduces the number of features while keeping as much information (variance) as possible.

The connection:

  1. Compute the covariance matrix of the data — a symmetric matrix describing how features vary together.
  2. Find its eigenvectors and eigenvalues.
  3. The eigenvectors are the principal components — the directions of maximum variance in the data.
  4. The eigenvalue of each eigenvector = the amount of variance captured along that direction.
  5. Keep the eigenvectors with the largest eigenvalues (most information) and drop the rest → dimensionality reduction.
Intuition

Picture a stretched, cigar-shaped cloud of 2-D data points. The long axis of the cloud is the eigenvector with the largest eigenvalue — the direction where the data varies most. Projecting every point onto just that one axis keeps most of the information while collapsing 2-D down to 1-D. That is PCA in a nutshell.

The eigenvalues also tell you how much you can safely discard: the explained variance ratio of a component is its eigenvalue divided by the sum of all eigenvalues.

Variance explained by component i=λiλ1+λ2++λn

See the full step-by-step eigen-decomposition worked example in the PCA note.

9. Other Key Applications

Application Role of Eigenvectors / Eigenvalues
Covariance & correlation analysis Eigenvectors of the covariance matrix expose the axes of greatest spread; eigenvalues quantify the spread — the foundation of PCA and whitening.
Spectral Clustering Build a graph of the data, form its Laplacian matrix, and use its smallest eigenvectors to embed points so clusters become linearly separable — great for non-spherical clusters that k-means fails on.
PageRank (Google) The ranking of web pages is the dominant eigenvector of the web's link matrix (eigenvalue λ=1) — the steady-state "importance" of each page.
Recommender Systems Matrix factorization (via SVD) uncovers latent factors — the eigen-directions of the user–item matrix — to predict missing ratings.
Image Compression Keeping only the top eigenvectors (largest eigenvalues) of an image reconstructs it with far less data (e.g., "eigenfaces" for face recognition).
Deep Learning stability Eigenvalues of the Hessian describe the curvature of the loss surface (conditioning, saddle points); eigenvalues of weight matrices relate to exploding/vanishing gradients.
Dynamical systems / RNNs The largest-magnitude eigenvalue of a transition/weight matrix governs whether repeated application makes signals grow, shrink, or stay stable.

10. Quick ML Example — Which Direction Carries the Signal?

Suppose after standardizing a small 2-feature dataset (e.g., height and weight) we compute the covariance matrix:

C=[1.00.80.81.0]

Its eigenvalues are λ1=1.8 and λ2=0.2 (using λ=1±0.8 for this symmetric form), with eigenvectors:

v1=[11](the 45 "size" axis),v2=[11](the "shape" axis)

Interpretation: v1 (large eigenvalue 1.8) captures 1.81.8+0.2=90% of the variance — tall people tend to be heavier, so most of the information lives along this combined "overall size" direction. We could keep only the v1 component and describe each person with a single number while losing just 10% of the variance. That is PCA reducing 2 features to 1.


11. Summary

Concept Meaning Formula
Matrix as transformation A square matrix moves/stretches vectors Av
Eigenvector v Direction unchanged by the transformation Av=λv
Eigenvalue λ How much the eigenvector is stretched/shrunk Av=λv
Characteristic equation How we solve for eigenvalues det(AλI)=0
Trace check Sum of eigenvalues = diagonal sum λi=trace(A)
Determinant check Product of eigenvalues λi=det(A)
Eigendecomposition Factoring a matrix into eigen-parts A=QΛQ1
PCA link Eigenvectors of covariance = principal components varianceλi

The Big Picture

  1. A matrix transforms vectors — usually changing their direction.
  2. Eigenvectors are the special directions that don't rotate; eigenvalues say how much they stretch.
  3. We find them by solving det(AλI)=0, then back-substituting.
  4. Eigendecomposition (A=QΛQ1) reveals the simple stretches hiding inside any diagonalizable matrix.
  5. In ML they find the directions that matter — maximum-variance axes in PCA, community structure in spectral clustering, and importance in PageRank.

The core takeaway: Eigenvectors are the natural axes of a transformation, and eigenvalues measure their importance. Whenever an ML method needs to find "the directions that matter most," eigenvectors and eigenvalues are doing the work.

12. Questions and Answers

  1. What does the equation Av=λv mean in plain words?
    Ans. Transforming the vector v with the matrix A produces the same result as simply scaling v by the number λ — i.e., v's direction is unchanged and it is only stretched/shrunk by λ.

  2. Can a non-square matrix have eigenvectors?
    Ans. No. Eigenvectors/eigenvalues are defined only for square (n×n) matrices. For rectangular matrices we use the closely related SVD (singular values) instead.

  3. Why do symmetric matrices (like covariance matrices) matter so much in ML?
    Ans. Symmetric matrices are guaranteed to have real eigenvalues and orthogonal (perpendicular) eigenvectors. Because a covariance matrix is symmetric, its eigenvectors form a clean set of perpendicular axes — exactly what PCA needs to define uncorrelated principal components.

  4. In PCA, what do a large vs. small eigenvalue tell you?
    Ans. A large eigenvalue means its eigenvector (principal component) captures a lot of the data's variance — keep it. A small eigenvalue means that direction carries little information — it can be dropped to reduce dimensionality with minimal loss.

  5. A 2×2 matrix has trace=6 and det=8. What are its eigenvalues?
    Ans. The eigenvalues satisfy λ1+λ2=6 and λ1λ2=8, giving λ=4 and λ=2.

See Also