What are eigenvalues and eigenvectors?
An eigenvector of a square matrix A is a nonzero vector whose direction does not change when A is applied: Av = λv. The number λ is its eigenvalue, the factor by which that vector is stretched, shrunk, or flipped. Together they describe what a matrix does along its own natural axes.
In machine learning, the eigenvectors of a covariance matrix are the principal components used in PCA. Eigenvalues of the Hessian describe the curvature of a loss surface and limit the learning rate gradient descent can use. They also govern whether repeated matrix multiplication blows up or dies out, which matters for recurrent networks, and the eigenvalues of a graph's Laplacian drive spectral clustering.
Key ideas
- An eigenvector keeps its direction under a matrix: Av = λv.
- The eigenvalue λ is the scale factor along that eigenvector, and a negative λ flips it.
- The trace is the sum of the eigenvalues, and the determinant is their product.
- Eigenvalues are the roots of the characteristic equation det(A − λI) = 0.
- Symmetric matrices have real eigenvalues and perpendicular eigenvectors.
- In PCA, the eigenvectors of the covariance matrix are the principal components.
Common questions
What do the eigenvalues of the Hessian tell you about training?
Each eigenvalue is the curvature of the loss along its eigenvector. At a critical point, all positive means a local minimum and mixed signs mean a saddle. For gradient descent on a quadratic, the learning rate must stay below 2/λ_max to avoid divergence, so the sharpest direction sets the speed limit.
Can eigenvalues be complex numbers?
Yes, for non-symmetric real matrices. A rotation by θ in the plane has eigenvalues cos θ ± i·sin θ, which signal turning rather than stretching. Complex eigenvalues always come in conjugate pairs for real matrices, and their magnitude still decides growth or decay.
What is a positive definite matrix?
A symmetric matrix whose eigenvalues are all positive, which is the same as xᵀAx > 0 for every nonzero x. Covariance matrices are positive semidefinite, with eigenvalues of zero or more. A positive definite Hessian at a critical point means the point is a strict local minimum.
Should I use numpy.linalg.eig or eigh?
Use eigh for symmetric or Hermitian matrices such as covariance matrices. It is faster, returns real eigenvalues in ascending order, and guarantees orthonormal eigenvectors. eig handles general square matrices but may return complex values, even from round-off on a matrix that should be symmetric.
Related explainers
- Linear Algebra — Vectors, matrices, and the language of data
- Singular Value Decomposition — Factor any matrix into rotation, scaling, and rotation — the Swiss army knife of linear algebra
- Dimensionality Reduction — PCA and t-SNE — seeing high-dimensional data
- Matrix Calculus & Jacobians — Partial derivatives, gradients, and the Jacobian — calculus for vectors
- Convexity, Minima & Saddle Points — Why some optimization problems are harder than others
- Recurrent Neural Networks — How RNNs read and understand sequences
References
- Strang, MIT 18.06 Linear Algebra, lecture 21 Eigenvalues and Eigenvectors
- Deisenroth, Faisal & Ong, "Mathematics for Machine Learning", ch. 4 Matrix Decompositions
- Pearson (1901), "On lines and planes of closest fit to systems of points in space"
Last updated