Introduction · Machine Learning

Linear Algebra

Watch lectures

Linear Algebra

1. Why It Matters

Every dataset is a matrix XX with nn rows (examples) and dd columns (features). Every model is matrix math: predictions, gradients, eigen-directions.

ypred=Xw+by_{pred} = X w + b

2. Objects

Object Shape Example
Scalar single number aa learning rate η=0.01η = 0.01
Vector xx in RdR^{d} x=[x1,x2,x3]x = [x₁, x₂, x₃]
Matrix AA in Rm×nR^{m × n} dataset XX
Tensor multi-way array image 224×224×3224 × 224 × 3

Transpose flips rows/cols. Dot product sums pairwise products.

3. Norms (size of vector)

  • L2L₂ :
∣∣x∣∣2=sum of xi2||x||₂ = \sqrt{\text{sum of } x_{i}²}
  • L1L₁ : sum of ∣xi∣|x_{i}|
  • Example: x=[3,4]x = [3, 4] → L2=5L₂ = 5, L1=7L₁ = 7.

4. Matrix Rules

If AA is m×nm × n and BB is n×pn × p, then C=ABC = A B is m×pm × p. Rules: AB≠BAA B ≠ B A in general,

(AB)T=BTAT(A B)^{T} = B^{T} A^{T}

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:
Av=λvA v = λ v

— vv only stretched by λλ. Example λ=5,2λ = 5, 2 for [41∣23][4 1 | 2 3].

  • SVD:
A=UΣVTA = U Σ V^{T}

— best rank-kk approximation, backbone of PCA and recommenders.

  • Gradient of squared loss uses transpose:
∇f=2XT(Xw−y)∇f = 2 X^{T} (X w - y)

6. Exam Points

  • Compute norm, inverse, eigenvalues of 2×2 — 5 marks, numerical favourite.
  • State (AB)T(A B)^{T} rule, AB≠BAA B ≠ B A — 2 marks.
  • SVD form + one ML use — 5 marks.
  • Link det = 0 → regularization — 3 marks.
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Machine Learning modules

Linear Algebra — Machine Learning — PYQDeck