Linear Algebra
1. Why It Matters
Every dataset is a matrix with rows (examples) and columns (features). Every model is matrix math: predictions, gradients, eigen-directions.
2. Objects
| Object | Shape | Example |
|---|---|---|
| Scalar | single number | learning rate |
| Vector | in | |
| Matrix | in | dataset |
| Tensor | multi-way array | image |
Transpose flips rows/cols. Dot product sums pairwise products.
3. Norms (size of vector)
- :
- : sum of
- Example: → , .
4. Matrix Rules
If is and is , then is . Rules: in general,
Never compute an explicit inverse in code — use QR / SVD solve.
A = [1 2 | 3 4], x = [5, 6] → A x = [17, 39]
computed as: 1*5+2*6=17, 3*5+4*6=39
5. Rank, Determinant, Eigen, SVD
- Rank: independent columns. Low rank → redundant features.
- det = 0 → singular, no unique solve (needs Ridge).
- Eigen:
— only stretched by . Example for .
- SVD:
— best rank- approximation, backbone of PCA and recommenders.
- Gradient of squared loss uses transpose:
6. Exam Points
- Compute norm, inverse, eigenvalues of 2×2 — 5 marks, numerical favourite.
- State rule, — 2 marks.
- SVD form + one ML use — 5 marks.
- Link det = 0 → regularization — 3 marks.