🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Machine Learning Notes
Topic #35

Eigenvalues

An eigenvalue tells you how much a special direction (its matching eigenvector) gets stretched or shrunk by a matrix transformation — without changing direction. This pair is the mathematical engine behind PCA.

Formula

\[ A\vec{v} = \lambda\vec{v} \]

\(A\) is a square matrix (the transformation), \(\vec{v}\) is an eigenvector (a direction that doesn't rotate under this transformation), and \(\lambda\) (lambda) is the eigenvalue — the scalar amount \(\vec{v}\) is stretched or shrunk by.

Solving for Eigenvalues — The Characteristic Equation

\[ \det(A - \lambda I) = 0 \]

For \(A = \begin{bmatrix}2&1\\1&2\end{bmatrix}\):

\[ \det\begin{bmatrix}2-\lambda&1\\1&2-\lambda\end{bmatrix} = (2-\lambda)^2 - 1 = \lambda^2 - 4\lambda + 3 = 0 \ \Rightarrow\ (\lambda-1)(\lambda-3)=0 \ \Rightarrow\ \lambda = 1,\ 3 \]
import numpy as np

A = np.array([[2, 1], [1, 2]])
eigenvalues, eigenvectors = np.linalg.eig(A)
print(eigenvalues)     # [3. 1.] (or [1. 3.], order isn't guaranteed)
print(eigenvectors)     # columns are the matching eigenvectors

Geometric Intuition

v (eigenvector) λv = 3v (same direction, scaled) u (not an eigenvector) Au (rotated — different direction)

An eigenvector keeps pointing the same way after the transformation — only its length changes, by a factor of λ.

Why This Matters for ML

PCA finds the eigenvectors of a dataset's covariance matrix — these directions are the axes along which the data varies the most (and least), ranked by their eigenvalues. See PCA for the full algorithm built on this idea.

Common Mistakes

  • Assuming every matrix has real-valued eigenvalues — some (like rotation matrices) have complex eigenvalues, though covariance matrices used in PCA are guaranteed to have real, non-negative eigenvalues.
  • Confusing the eigenvalue (a single number, the scale factor) with the eigenvector (a direction/vector).

Interview Relevance

Q: "What do the eigenvalues of a covariance matrix represent in PCA?" Each eigenvalue represents the amount of variance in the data along its corresponding eigenvector's direction — sorting by eigenvalue tells you which directions capture the most information.

Practice Question

For \(A = \begin{bmatrix}4&0\\0&1\end{bmatrix}\), identify the eigenvalues by inspection (hint: diagonal matrices make this direct) without solving the characteristic equation.

Want to go beyond the notes?

Join CodingNow 2.0's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Eigenvalues – FAQs

Quick answers about learning Eigenvalues in Machine Learning.

This free note from CodingNow 2.0 explains Eigenvalues in Machine Learning — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Machine Learning topic on CodingNow 2.0, including Eigenvalues, is 100% free with no signup required.
With focused practice, most students grasp Eigenvalues in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now