TIMED REVISION · 1-MINUTE PANIC SHEETS

Machine Learning 10-Minute Rapid Revision

For the last few minutes before the exam hall: one core rule per topic, the formulas you must remember, and the traps that cost marks.

PANIC SHEET 01 · Linear Regression & Regularization (OLS, Ridge, Lasso)

Ordinary Least Squares (OLS) & Normal Equation Derivations

Full Lesson →
CORE INVARIANT ANCHOR:

“The OLS weight vector w* = (X^T X)^{-1} X^T y projects target vector y orthogonally onto the Column Space Col(X).”

Must-Remember Principles:
  • —Residual Sum of Squares (RSS): RSS(w) = ||y - Xw||_2^2 = (y - Xw)^T (y - Xw) = y^T y - 2 w^T X^T y + w^T X^T X w.
  • —Matrix Gradient: grad_w RSS(w) = -2 X^T y + 2 X^T X w = 0.
  • —Normal Equations: (X^T X) w* = X^T y.
  • —Projection Matrix (Hat Matrix): H = X (X^T X)^{-1} X^T. Hat matrix is symmetric (H^T = H) and idempotent (H^2 = H).
  • —Predicted Values: y_hat = H y. Residual Vector: e = y - y_hat = (I - H) y.
  • —Gauss-Markov Theorem: Under homoscedastic and uncorrelated errors, OLS estimator is BLUE (Best Linear Unbiased Estimator).
Critical Exam Pitfalls:
  • —The matrix X^T X is invertible if and only if design matrix X has FULL COLUMN RANK (columns of X are linearly independent).
  • —If features are collinear (multicollinearity), Det(X^T X) = 0 and OLS fails to yield a unique solution.
PANIC SHEET 02 · Linear Regression & Regularization (OLS, Ridge, Lasso)

Ridge (L2) vs Lasso (L1) Regularization & Geometric Sparsity

Full Lesson →
CORE INVARIANT ANCHOR:

“Ridge adds an L2 spherical ball penalty shrinking weights smoothly. Lasso adds an L1 diamond penalty driving weights to exact zeros.”

Must-Remember Principles:
  • —Ridge Objective (L2): min_w ||y - Xw||_2^2 + lambda * ||w||_2^2.
  • —Ridge Closed Form: w*_{ridge} = (X^T X + lambda * I)^{-1} X^T y.
  • —Lasso Objective (L1): min_w ||y - Xw||_2^2 + lambda * ||w||_1.
  • —SVD Representation of Ridge: w*_{ridge} = V (D^2 + lambda I)^{-1} D U^T y = Sum_{j=1}^d [ d_j^2 / (d_j^2 + lambda) ] * (u_j^T y / d_j) * v_j.
  • —Lasso Soft-Thresholding: For orthonormal X, w_j* = sign(w_j^{ols}) * max(0, |w_j^{ols}| - lambda/2).
Critical Exam Pitfalls:
  • —Ridge regression NEVER produces sparse weight vectors (weights approach zero asymptotically but rarely equal exact 0).
  • —Lasso has NO closed-form matrix solution because the L1 norm |w| has non-differentiable corners at w = 0.
PANIC SHEET 03 · Logistic Regression, k-NN, Naive Bayes & LDA

Logistic Regression, Logit Link & Cross-Entropy Optimization

Full Lesson →
CORE INVARIANT ANCHOR:

“Logistic Regression is a linear classifier because the log-odds (logit) is a linear combination of features: ln(p / (1 - p)) = w^T x.”

Must-Remember Principles:
  • —Sigmoid Function: sigma(z) = 1 / (1 + e^{-z}) = e^z / (1 + e^z).
  • —Sigmoid Derivative: d sigma(z) / dz = sigma(z) * (1 - sigma(z)).
  • —Odds Ratio: Odds = p / (1 - p). Logit: ln(Odds) = w^T x + b.
  • —Binary Cross-Entropy Loss: J(w) = - (1/n) * Sum_{i=1}^n [ y_i * ln(p_i) + (1 - y_i) * ln(1 - p_i) ].
  • —Gradient of Cross-Entropy: grad_w J(w) = (1/n) * X^T (p - y), identical in form to OLS gradient!
Critical Exam Pitfalls:
  • —Logistic regression predicts probabilities, but the decision boundary (where p = 0.5 => w^T x = 0) is strictly HYPERPLANAR (linear).
PANIC SHEET 04 · Logistic Regression, k-NN, Naive Bayes & LDA

k-Nearest Neighbors & Naive Bayes with Laplace Smoothing

Full Lesson →
CORE INVARIANT ANCHOR:

“In k-NN, k=1 has maximum variance (overfitting); large k has maximum bias (underfitting). Naive Bayes uses conditional independence P(x|y) = Prod P(xi|y).”

Must-Remember Principles:
  • —Euclidean Distance: d(x, z) = sqrt( Sum_{j=1}^d (x_j - z_j)^2 ). Manhattan: d(x, z) = Sum |x_j - z_j|.
  • —Minkowski Metric: d_p(x, z) = ( Sum |x_j - z_j|^p )^{1/p}.
  • —Naive Bayes Posterior: P(y=c | x) proportional to P(y=c) * Product_{j=1}^d P(x_j | y=c).
  • —Laplace (Add-1) Smoothing: P(x_j = v | y=c) = ( Count(x_j=v, y=c) + 1 ) / ( Count(y=c) + |V_j| ), where |V_j| is the number of possible values for feature j.
Critical Exam Pitfalls:
  • —When calculating Laplace smoothing, the denominator must add |V_j| (the number of distinct values feature j can take), NOT the total number of classes.
PANIC SHEET 05 · Logistic Regression, k-NN, Naive Bayes & LDA

Linear Discriminant Analysis (LDA) & Fisher's Criterion

Full Lesson →
CORE INVARIANT ANCHOR:

“LDA projects data onto a direction w that maximizes between-class variance relative to within-class variance: w* = S_W^{-1} (mu_1 - mu_2).”

Must-Remember Principles:
  • —Fisher's Criterion Objective: J(w) = (w^T S_B w) / (w^T S_W w), where S_B is between-class scatter and S_W is within-class scatter.
  • —Between-Class Scatter (Binary): S_B = (mu_1 - mu_2) (mu_1 - mu_2)^T (Rank 1 matrix).
  • —Within-Class Scatter: S_W = S_1 + S_2 = Sum_{x in C_1} (x - mu_1)(x - mu_1)^T + Sum_{x in C_2} (x - mu_2)(x - mu_2)^T.
  • —Optimal Projection Vector: w* = S_W^{-1} (mu_1 - mu_2). Derived by setting grad_w J(w) = 0 and solving the generalized eigenvalue problem S_B w = lambda S_W w.
  • —Maximum Projected Dimensions: For C classes, rank(S_B) <= C - 1. Therefore, LDA can project into at most C - 1 dimensions.
  • —Bayes Optimality Assumptions: LDA is equivalent to the Bayes optimal classifier if class-conditional distributions are Gaussian N(mu_c, Sigma) with IDENTICAL (shared) covariance matrices Sigma_1 = Sigma_2 = ... = Sigma_C.
  • —LDA vs QDA: If class covariance matrices are unequal (Sigma_1 != Sigma_2), the quadratic term in the log-posterior does not cancel, yielding Quadratic Discriminant Analysis (QDA).
Critical Exam Pitfalls:
  • —LDA requires S_W to be INVERTIBLE (full rank). If number of features d > number of samples n (high-dimensional regime), S_W is singular. PCA is often applied first (PCA-LDA).
  • —LDA is a SUPERVISED dimensionality reduction and classification method (uses class labels to maximize separation), whereas PCA is UNSUPERVISED (maximizes total data variance without knowing labels).
  • —For C classes, the maximum number of discriminant directions is min(d, C - 1). For binary classification (C = 2), LDA projects to at most 1 dimension!
PANIC SHEET 06 · Decision Trees (ID3, CART) & Ensemble Methods

Decision Trees: Shannon Entropy, Information Gain & Gini Index

Full Lesson →
CORE INVARIANT ANCHOR:

“ID3 splits on Maximum Information Gain using Entropy. CART splits on Minimum Gini Impurity (binary splits).”

Must-Remember Principles:
  • —Shannon Entropy: H(S) = - Sum_{c=1}^C p_c log_2(p_c). Max entropy = log_2(C) (uniform distribution); Min entropy = 0 (pure).
  • —Information Gain: Gain(S, A) = H(S) - Sum_{v in Values(A)} [ |S_v| / |S| ] * H(S_v).
  • —Gini Impurity: Gini(S) = 1 - Sum_{c=1}^C p_c^2. For binary classification, Gini_max = 0.5 (at p=0.5).
  • —Variance Reduction (Regression Trees): Variance = (1/N) Sum (y_i - y_bar)^2.
Critical Exam Pitfalls:
  • —Information Gain is biased towards features with numerous distinct values (e.g. ID numbers). Gain Ratio normalizes by Split Information.
PANIC SHEET 07 · Decision Trees (ID3, CART) & Ensemble Methods

Ensemble Learning: Random Forests, Bagging & AdaBoost

Full Lesson →
CORE INVARIANT ANCHOR:

“Bagging (Random Forests) reduces VARIANCE by averaging independent models. Boosting (AdaBoost) reduces BIAS by sequentially correcting weak learners.”

Must-Remember Principles:
  • —Bootstrap Sampling Probability: Probability a sample is NOT selected in N draws = (1 - 1/N)^N -> 1/e ≈ 36.8% (Out-of-Bag data).
  • —Random Forest Feature Subsampling: For classification with d features, split across floor(sqrt(d)) randomly chosen features at each node.
  • —AdaBoost Classifier Weight: alpha_m = (1/2) * ln( (1 - eps_m) / eps_m ), where eps_m is weighted error.
  • —AdaBoost Sample Weight Update: w_{i, m+1} = w_{i, m} * exp( - alpha_m * y_i * h_m(x_i) ) / Z_m.
Critical Exam Pitfalls:
  • —Random Forests do NOT overfit as the number of trees increases (generalization error converges to a finite bound by Strong Law of Large Numbers).
PANIC SHEET 08 · Support Vector Machines (SVM) & Kernel Methods

SVM Maximum Margin Hyperplane & Dual Optimization

Full Lesson →
CORE INVARIANT ANCHOR:

“Maximizing geometric margin 2/||w|| is equivalent to minimizing (1/2)||w||^2 subject to y_i(w^T x_i + b) >= 1.”

Must-Remember Principles:
  • —Primal Hard-Margin Problem: min_{w, b} (1/2) ||w||_2^2 s.t. y_i (w^T x_i + b) >= 1 for all i.
  • —Primal Soft-Margin Problem: min_{w, b, xi} (1/2) ||w||_2^2 + C Sum_{i=1}^n xi_i s.t. y_i (w^T x_i + b) >= 1 - xi_i, xi_i >= 0.
  • —Dual Formulation: max_{alpha} Sum alpha_i - (1/2) Sum_{i, j} alpha_i alpha_j y_i y_j (x_i^T x_j) s.t. 0 <= alpha_i <= C and Sum alpha_i y_i = 0.
  • —Weight Recovery: w* = Sum_{i=1}^n alpha_i y_i x_i. Only Support Vectors have alpha_i > 0!
  • —KKT Complementary Slackness: alpha_i * [ y_i (w^T x_i + b) - 1 + xi_i ] = 0.
Critical Exam Pitfalls:
  • —Non-support vectors have alpha_i = 0 and have ZERO influence on the resulting hyperplane.
  • —Large C penalizes margin violations heavily (approaches hard-margin, risks overfitting). Small C allows wider margin with more violations (higher bias).
PANIC SHEET 09 · Support Vector Machines (SVM) & Kernel Methods

The Kernel Trick, Mercer's Theorem & RBF Kernels

Full Lesson →
CORE INVARIANT ANCHOR:

“The Kernel Trick replaces inner product x_i^T x_j with K(x_i, x_j) = phi(x_i)^T phi(x_j), mapping data to high dimensions without explicit transformation.”

Must-Remember Principles:
  • —Mercer's Theorem: A symmetric function K(x, z) is a valid kernel iff its Gram Matrix K_{ij} = K(x_i, x_j) is Positive Semi-Definite for any dataset.
  • —Linear Kernel: K(x, z) = x^T z.
  • —Polynomial Kernel: K(x, z) = (x^T z + c)^d (Dimension of feature space is (d + n)! / (d! n!)).
  • —Gaussian / Radial Basis Function (RBF) Kernel: K(x, z) = exp( - gamma * ||x - z||^2 ) = exp( - ||x - z||^2 / (2 sigma^2) ).
  • —RBF Dimension: Corresponds to an INFINITE-dimensional feature Hilbert space via Taylor series expansion of exp(.)!
Critical Exam Pitfalls:
  • —Large gamma in RBF kernel leads to a narrow Gaussian bell curve (overfitting / memorizing data points). Small gamma leads to oversmoothing (underfitting).
PANIC SHEET 10 · Multilayer Perceptrons & Backpropagation Math

Multilayer Perceptrons, Non-Linear Activations & Vanishing Gradients

Full Lesson →
CORE INVARIANT ANCHOR:

“A neural network without non-linear activation functions collapses into a single-layer linear model: W2 * (W1 * x) = (W2 * W1) * x = W_eff * x.”

Must-Remember Principles:
  • —Universal Approximation Theorem (Cybenko 1989): A feedforward network with a single hidden layer containing finite non-linear neurons can approximate any continuous function on compact subsets of R^n.
  • —Sigmoid: sigma(z) = 1 / (1 + e^{-z}); max derivative is 0.25 (at z=0). Causes vanishing gradients in deep networks!
  • —Tanh: tanh(z) = (e^z - e^{-z}) / (e^z + e^{-z}); zero-centered; max derivative is 1.0 (at z=0).
  • —ReLU: ReLU(z) = max(0, z); Derivative is 1 for z > 0, 0 for z < 0. Avoids vanishing gradient for positive activations.
  • —Leaky ReLU: max(alpha * z, z) with alpha ≈ 0.01 to prevent the 'Dying ReLU' problem.
Critical Exam Pitfalls:
  • —Initializing all weights to zero in a neural network causes SYMMETRIC updates across all hidden neurons, preventing the network from learning diverse features.
PANIC SHEET 11 · Multilayer Perceptrons & Backpropagation Math

The Backpropagation Algorithm: Multivariable Chain Rule Derivation

Full Lesson →
CORE INVARIANT ANCHOR:

“Backpropagation propagates the error delta_j backward using the chain rule: dL/dw_{jk} = delta_j * a_k.”

Must-Remember Principles:
  • —Forward Pass: z_j^{(l)} = Sum_k w_{jk}^{(l)} a_k^{(l-1)} + b_j^{(l)}; a_j^{(l)} = g(z_j^{(l)}).
  • —Output Error Delta: delta_j^{(L)} = ( dL / da_j^{(L)} ) * g'(z_j^{(L)}). For MSE + Linear: delta_j = (a_j - y_j).
  • —Hidden Error Delta: delta_k^{(l-1)} = ( Sum_j w_{jk}^{(l)} delta_j^{(l)} ) * g'(z_k^{(l-1)}).
  • —Weight Gradient: dL / dw_{jk}^{(l)} = delta_j^{(l)} * a_k^{(l-1)}.
  • —Bias Gradient: dL / db_j^{(l)} = delta_j^{(l)}.
Critical Exam Pitfalls:
  • —Weight update subtraction: w_{new} = w_{old} - eta * (dL/dw). A common exam sign error is adding instead of subtracting the gradient.
PANIC SHEET 12 · Clustering, PCA & Model Evaluation Metrics

Clustering Algorithms: K-Means, K-Medoids & Hierarchical Linkages

Full Lesson →
CORE INVARIANT ANCHOR:

“K-Means alternates Assignment (nearest centroid) and Update (mean of cluster). Single Linkage uses MIN distance (chaining effect); Complete Linkage uses MAX distance (compact spheres).”

Must-Remember Principles:
  • —Within-Cluster Sum of Squares (Inertia): WCSS = Sum_{k=1}^K Sum_{x in C_k} ||x - mu_k||_2^2.
  • —Centroid Update: mu_k = (1 / |C_k|) * Sum_{x in C_k} x.
  • —Single Linkage Distance: D(A, B) = min_{x in A, y in B} d(x, y).
  • —Complete Linkage Distance: D(A, B) = max_{x in A, y in B} d(x, y).
  • —Average Linkage Distance: D(A, B) = [ 1 / (|A| * |B|) ] * Sum_{x in A} Sum_{y in B} d(x, y).
Critical Exam Pitfalls:
  • —K-Means converges to a LOCAL minimum of WCSS, not necessarily the global optimum. Different random initializations produce different final clusters.
  • —K-Means is heavily sensitive to outliers because the squared Euclidean distance penalizes distant points quadratically.
PANIC SHEET 13 · Clustering, PCA & Model Evaluation Metrics

Dimensionality Reduction: Principal Component Analysis (PCA) & t-SNE

Full Lesson →
CORE INVARIANT ANCHOR:

“PCA finds orthogonal directions that maximize data variance (eigenvectors of covariance matrix Sigma = (1/n) X^T X).”

Must-Remember Principles:
  • —Sample Covariance Matrix: Sigma = (1 / n) * X^T X (assuming zero-mean centered X).
  • —Eigenvalue Problem: Sigma v_i = lambda_i v_i. Principal components are sorted by lambda_1 >= lambda_2 >= ... >= lambda_d >= 0.
  • —Total Variance: Sum_{i=1}^d lambda_i = Trace(Sigma).
  • —Explained Variance Ratio of k components: Proportion = (Sum_{i=1}^k lambda_i) / (Sum_{j=1}^d lambda_j).
  • —t-SNE vs PCA: PCA is a global linear projection. t-SNE is a local non-linear manifold visualizer using Student-t distribution in low dimensions to prevent the crowding problem.
Critical Exam Pitfalls:
  • —Data MUST be mean-centered before applying PCA; otherwise the first principal component points toward the data mean rather than the direction of maximum variance.
PANIC SHEET 14 · Clustering, PCA & Model Evaluation Metrics

Model Evaluation: Confusion Matrix, ROC-AUC & Bias-Variance Decomposition

Full Lesson →
CORE INVARIANT ANCHOR:

“Precision = TP / (TP + FP). Recall (Sensitivity, TPR) = TP / (TP + FN). Specificity (TNR) = TN / (TN + FP). FPR = 1 - Specificity.”

Must-Remember Principles:
  • —F1-Score: 2 * (Precision * Recall) / (Precision + Recall) = 2 * TP / (2*TP + FP + FN).
  • —ROC Curve: Plots True Positive Rate (Recall) on Y-axis vs False Positive Rate (FPR) on X-axis across varying threshold tau.
  • —ROC-AUC: Area under ROC curve; random guess gives AUC = 0.5; perfect model gives AUC = 1.0.
  • —Bias-Variance Decomposition: E[(y - f_hat(x))^2] = [ Bias(f_hat(x)) ]^2 + Var(f_hat(x)) + sigma^2, where sigma^2 is irreducible noise.
  • —k-Fold Cross-Validation: Partitions dataset into k equal folds; trains on (k-1) and tests on 1, repeated k times.
Critical Exam Pitfalls:
  • —Accuracy is a dangerously misleading metric for class-imbalanced datasets (e.g. 99% accuracy on 99% negative class by predicting all negatives). Use F1-score or PR-AUC.
PANIC SHEET 15 · Clustering, PCA & Model Evaluation Metrics

Cross-Validation: Hold-Out, k-Fold and Leave-One-Out

Full Lesson →
CORE INVARIANT ANCHOR:

“Train on part, test on the rest, repeat, average. k-fold = k fits; LOOCV = n fits.”

Must-Remember Principles:
  • —CV₍ₖ₎ = (1/k) Σ MSEᵢ
  • —Train size in k-fold = n(k − 1)/k
  • —LOOCV (least squares) = (1/n) Σ ((yᵢ − ŷᵢ)/(1 − hᵢ))²
Critical Exam Pitfalls:
  • —LOOCV: low bias, high variance
  • —No preprocessing on the full data before splitting
  • —Refit the chosen model on all data
  • —Stratify classes; don't shuffle time series