Home / Formulas / MLT
MLT formula sheet
Collected automatically from the lessons. Print it, or read it the night before.
Week 1 - PCA: finding the best view of your data
- Centre: xi←xi−xˉ; C=n1XXT
- Variance along unit w: wTCw; best w: Cw=λw, top λ
- Coordinates z=WTx; reconstruction x^=WWTx
- Variance explained =λ1+⋯+λdλ1+⋯+λk; error =λk+1+⋯+λd
- SVD link: λj=σj2/n
Week 2 - Kernel PCA: curved views of data
- k(x,y)=ϕ(x)Tϕ(y); (xTy)2↔ϕ=(x12,2x1x2,x22)
- RBF: exp(−∥x−y∥2/2σ2); polynomial (xTy+c)d
- Valid ⟺ K=KT, K⪰0
- Centring: K~=K−1nK−K1n+1nK1n
- Coordinates on component j: μjvj,i; variance along it μj/n
Week 3 - K-means: grouping without labels
- F=∑i∥xi−μzi∥2; assign zi=argmink∥xi−μk∥2; update μk=mean(Ck)
- k-means++: P(x)=D(x)2/∑D2; E[F]≤8(lnk+2)Fopt
- Kernel distance: k(x,x)−∣C∣2∑jk(x,xj)+∣C∣21∑j,lk(xj,xl)
Week 4 - MLE, Bayes, Gaussian mixtures and EM
- Beta posterior: Beta(α+h,β+t); mean α+β+nα+h; MAP α+β+n−2α+h−1; MLE nh
- Beta mean α+βα; variance (α+β)2(α+β+1)αβ
- GMM: p(x)=∑kπkN(x∣μk,Σk)
- rik=∑jπjNj(xi)πkNk(xi); nk=∑irik; πk=nnk; μk=nk∑rikxi; Σk=nk∑rik(xi−μk)(⋅)T
- Parameters: full K(d+2d(d+1))+K−1; diagonal 2Kd+K−1; spherical K(d+1)+K−1
Week 5 - Regression: least squares and its Bayesian view
- y^=Xw; L=∥y−Xw∥2; ∇L=−2XT(y−Xw)
- w∗=(XTX)−1XTy; gradient step w←w+2ηXT(y−Xw)
- MSE =n1∑(yi−y^i)2; R2=1−SStotSSres
- LOOCV =n1∑i(yi−y^i(−i))2
Week 6 - Ridge and LASSO: taming overfitting
- Ridge: w=(XTX+λI)−1XTy; 1-D: ∑x2+λ∑xy; per-feature shrink 1+λz
- LASSO soft-threshold: sign(z)max(∣z∣−λ/2,0)
- MAP: Gaussian prior →λ=σ2/τ2 (ridge); Laplace prior → LASSO
Week 7 - k-NN and decision trees
- Euclidean distance ∥x−q∥; k-NN regression: mean of k neighbours
- Entropy H=−∑cpclog2pc (50/50 gives 1; 75/25 gives 0.811)
- Gini =1−∑pc2 (50/50 gives 0.5; 75/25 gives 0.375)
- IG=H(parent)−∑jnnjH(childj)
Week 8 - Generative models: Naive Bayes
- P(y∣x)∝P(y)∏jP(xj∣y)
- Laplace: total+Vcount+1 (words) or nc+2count+1 (yes/no)
- Parameters (binary): naive Cd+C−1; full C(2d−1)+C−1
- Gaussian NB: N(xj∣μjc,σjc2) with class-wise MLE
Week 9 - Perceptron and logistic regression
- Perceptron: mistake if ywTx≤0; update w←w+yx; mistakes ≤(R/γ)2
- Logistic: p=σ(wTx)=1+e−wTx1; ln1−pp=wTx
- Loss −∑[ylnp+(1−y)ln(1−p)]; gradient ∑(pi−yi)xi; step w←w−η∇L
Week 10 - Support vector machines
- Primal: min21∥w∥2+C∑ξi s.t. yi(wTxi+b)≥1−ξi, ξi≥0
- Margin =∥w∥2
- Dual: max∑αi−21∑ijαiαjyiyjk(xi,xj); 0≤αi≤C; ∑αiyi=0
- w=∑αiyixi; f(x)=∑αiyik(xi,x)+b
- Hinge loss: max(0,1−yf(x))
Week 11 - Bagging, boosting and AdaBoost
- Average of n independent: σ2/n; correlated: ρσ2+n1−ρσ2
- OOB probability (1−n1)n→e−1≈0.368
- AdaBoost: εt=∑wrongwi; αt=21lnεt1−εt; wi←wie−αtyiht(xi); H=sign∑αtht
Week 12 - Neural networks
- h=g(Wx+b); ReLU max(0,z); sigmoid 1+e−z1 with derivative σ(1−σ)
- Softmax pk=ezk/∑jezj; loss −lnpy
- Parameters per layer: mn+n
- Chain rule: ∂w1∂L=∂y^∂L∂h∂y^∂w1∂h