Linear Algebra for ML
Vectors, matrices, dot products, projections and decompositions: the language in which data, models and embeddings are written.
Beginner · about 18 hours · difficulty 3/5
Learn first: NumPy and Array Thinking
A dataset is a matrix, a linear model is a matrix-vector product, and a neural network layer is a matrix multiply followed by a nonlinearity. Linear algebra is how you reason about all of them.
Concepts to own
- Vectors and dot products: similarity, angles, and why cosine similarity drives search over embeddings.
- Matrices as transformations: rotation, scaling, projection; matrix multiplication as composition.
- Norms: L1 and L2 norms reappear as regularization penalties.
- Rank, span and linear independence: why duplicated features break ordinary least squares.
- Eigenvalues and eigenvectors: the core of PCA and of understanding covariance.
- Singular value decomposition (SVD): low-rank approximation, PCA, recommender systems, LoRA.
How to study
Build geometric intuition first (the 3Blue1Brown series), then verify every idea in NumPy: multiply matrices, check shapes, compute an SVD and reconstruct the matrix. You do not need proofs; you need to predict shapes and interpret results.
Good enough to move on when you can explain PCA as finding directions of maximum variance using eigenvectors of the covariance matrix, and implement it with np.linalg.svd.
Key concepts
- Vectors, dot product and cosine similarity
- Matrix multiplication and shapes
- Norms
- Rank and linear independence
- Eigenvalues and eigenvectors
- SVD and low-rank approximation
- Matrix calculus notation
Mini project
Compress a grayscale image with truncated SVD in NumPy, plot reconstructions at ranks 5, 20 and 50, and chart how much of the total energy (sum of squared singular values) each rank keeps.
Check yourself
If a feature matrix has two perfectly correlated columns, what happens to its rank and why does that matter for linear regression?
Free resources
- Essence of Linear Algebra (3Blue1Brown)
- Mathematics for Machine Learning (Deisenroth, Faisal, Ong)