What are vectors and matrices, and why is linear algebra behind machine learning?
Linear algebra has a reputation as the dry course between calculus and "real" maths. In practice, it's the engine under computer graphics, search engines, physics simulations and modern AI.
Vectors: lists with meaning
A vector is an ordered list of numbers. Geometrically, (3, 4) is an arrow from the origin to a point, with length 5. But vectors can represent anything with several components: an RGB colour, a customer's purchase history, or the pixel values of an image.
Key operations:
- Addition – combine arrows tip to tail.
- Scaling – stretch or shrink.
- Dot product – measures how aligned two vectors are. This underlies "similarity" in recommendation systems and search.
Matrices: transformations
A matrix is a grid of numbers, but the useful way to think of it is as a function that transforms vectors: rotating, stretching, shearing or projecting them. Multiplying matrices means applying one transformation after another.
Why machine learning runs on it
- Data as matrices – a dataset of 10,000 examples with 50 features is a 10,000 × 50 matrix.
- Neural network layers – each layer is essentially a matrix multiplication followed by a simple non-linear function. Training adjusts the numbers in those matrices.
- Embeddings – words, images and users are represented as vectors, so "closeness" in meaning becomes closeness in space.
- Hardware – GPUs are fast at doing huge numbers of matrix multiplications in parallel, which is a big reason deep learning took off.
Concepts worth learning next
Eigenvalues and eigenvectors (directions a transformation only stretches), matrix rank, and singular value decomposition, which powers compression and dimensionality reduction.
Questions: What resource made linear algebra click for you? Is it better to learn it geometrically first or computationally first?
Comments · 4
A neural network layer is basically a matrix multiplication. Once you see that, a lot of ML jargon gets less scary.
NumPy made matrices click for me. Writing the loops by hand then replacing them with one dot product was an aha moment.
Which topics should I focus on first if I only have a few weeks? Dot products, matrix multiplication, eigenvalues?
Dot products and matrix multiplication first, then maybe eigenvalues and SVD. That covers the core of what ML uses.