ML Notes
Essential linear algebra concepts for ML including vectors, matrices, eigenvalues, and their applications in algorithms like PCA, SVD, and neural networks.
Linear algebra is the mathematical backbone of machine learning. Every dataset is a matrix, every model learns weight vectors, and transformations like PCA are eigenvalue decompositions. You don't need a PhD in math — but understanding these core concepts will make you a much better ML practitioner.
Why Linear Algebra Matters in ML
| ML Concept | Linear Algebra Operation |
| Dataset | Matrix (n × d) |
| Features | Vectors in d-dimensional space |
| Linear regression | Solving system of equations |
| PCA | Eigenvalue decomposition |
| Neural networks | Matrix multiplications + nonlinearities |
| Embeddings | Vectors in high-dimensional space |
Vectors
A vector is an ordered list of numbers representing a point or direction in space.
Matrices
A matrix is a 2D array of numbers. In ML, your dataset IS a matrix.
Eigenvalues and Eigenvectors
Eigenvectors are directions that don't change under a transformation — they only get scaled by the eigenvalue. This is the math behind PCA.
Singular Value Decomposition (SVD)
SVD decomposes any matrix into three components. It's used in dimensionality reduction, recommendations, and image compression.
Linear Algebra in Neural Networks
Key Concepts Summary
| Concept | ML Application |
|---|---|
| Dot product | Similarity, projections, linear models |
| Matrix multiply | Neural network layers, transformations |
| Transpose | Gradient computation, covariance |
| Inverse | Analytical solutions (normal equation) |
| Eigendecomposition | PCA, spectral clustering |
| SVD | Dimensionality reduction, recommendations |
| Norms | Regularization (L1, L2), distance |
Interview Questions
- What is the geometric interpretation of a dot product?
The dot product measures the projection of one vector onto another. It equals |a|*|b|*cos(θ), so it's related to the angle between vectors.
- Why is matrix multiplication the core of neural networks?
Each layer computes z = Wx + b, which is a linear transformation that combines inputs using learned weights. Stacking these with nonlinearities creates powerful function approximators.
- What is PCA doing mathematically?
PCA finds the eigenvectors of the covariance matrix and projects data onto the top-k eigenvectors (directions of maximum variance).
- When would you use SVD vs eigendecomposition?
SVD works on any matrix (even non-square), eigendecomposition requires square matrices. SVD is more numerically stable and is preferred in practice.
- What is the rank of a matrix and why does it matter in ML?
Rank is the number of linearly independent rows/columns. Low-rank matrices indicate redundancy in features. Matrix factorization exploits low-rank structure for compression and recommendations.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Linear Algebra for Machine Learning.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Machine Learning topic.
Search Terms
machine-learning, machine learning, machine, learning, prerequisites, linear, algebra, for
Related Machine Learning Topics