📝 Chapter Notes: ML Foundations
Quick-reference summary of all key concepts, formulas, and GATE tips from Chapter 8.
1. Types of Machine Learning
- Supervised: Labelled data → Classification (discrete) or Regression (continuous)
- Unsupervised: No labels → Clustering, Dimensionality Reduction, Association Rules
- Semi-supervised: Small labelled + large unlabelled data
- Reinforcement: Agent learns through rewards/penalties in an environment
Tom Mitchell’s Definition: “A program learns from Experience E with respect to Task T and Performance measure P if its performance at T, as measured by P, improves with experience E.”
2. Supervised Learning — Key Formulas
Linear Regression (Normal Equation)
w* = (XᵀX)⁻¹Xᵀy
MSE Cost
J(w) = (1/2n) ∑(yᵢ − wᵀxᵢ)²
Sigmoid Function
σ(z) = 1 / (1 + e⁻ᶲ)
Cross-Entropy Loss
L = −[y log(p) + (1−y) log(1−p)]
Entropy
H(S) = −∑ pᵢ log&sub2;(pᵢ)
Information Gain
IG(S,A) = H(S) − ∑ (|Sᵥ|/|S|) H(Sᵥ)
Gini Impurity
Gini(S) = 1 − ∑ pᵢ²
3. Unsupervised Learning — Key Formulas
K-Means Objective
J = ∑ₖ ∑(xᵢ ∈ Cₖ) ||xᵢ − μₖ||²
Silhouette Score
s(i) = (b(i) − a(i)) / max(a(i), b(i))
PCA: Explained Variance Ratio
EVRₖ = λₖ / ∑λᵢ
4. Bias-Variance Tradeoff
Decomposition
E[(y − f̂)²] = Bias² + Variance + σ²
- High Bias: Simple models (linear regression, small tree) → Underfitting
- High Variance: Complex models (deep tree, KNN with K=1) → Overfitting
- σ² = irreducible error (noise in data)
5. Regularization Quick Reference
Ridge (L2)
J = MSE + λ ∑wᵢ²
Lasso (L1)
J = MSE + λ ∑|wᵢ|
Elastic Net
J = MSE + λ&sub1;∑|wᵢ| + λ&sub2;∑wᵢ²
- Ridge: shrinks coefficients, never zeros them
- Lasso: can zero out coefficients (feature selection)
- Larger λ = more regularization = simpler model
6. Cross-Validation Quick Facts
- K-Fold: K models trained, each sample validated once. Common: K=5 or K=10.
- LOOCV (K=n): Nearly unbiased but high variance. Deterministic (no shuffle).
- Stratified: Preserves class distribution. Essential for imbalanced data.
- Bootstrap OOB: ~36.8% of data is out-of-bag in each sample (e⁻¹).
7. Evaluation Metrics Cheat Sheet
Accuracy(TP+TN) / (TP+TN+FP+FN)
PrecisionTP / (TP+FP)
RecallTP / (TP+FN)
F1-Score2×P×R / (P+R) = 2TP/(2TP+FP+FN)
SpecificityTN / (TN+FP)
ROCTPR vs FPR; AUC=1 perfect, AUC=0.5 random
R²1 − SS_res/SS_tot
Adjusted R²1 − ((1−R²)(n−1))/(n−p−1)
💡 Remember: FP = Type I error (false alarm). FN = Type II error (miss). For imbalanced data, never rely on accuracy alone — use F1 or AUC.
8. Feature Engineering Essentials
Min-Maxx' = (x−x_min)/(x_max−x_min)
Z-Scorez = (x−μ)/σ
- One-hot encode nominal features; label encode ordinal features
- Drop one dummy to avoid multicollinearity (K−1 encoding)
- Fit scaler on training data only; transform test data with same params
- Curse of dimensionality: samples needed grow exponentially with features
9. Math Essentials Quick Reference
Gradient Descent Updatew ← w − η∇L
MLEθ_MLE = argmax ∑ log P(xᵢ|θ)
MAPθ_MAP = argmax [log P(D|θ) + log P(θ)]
BayesP(A|B) = P(B|A)P(A)/P(B)
EigenvalueAv = λv; det(A−λI)=0
- MAP with Gaussian prior = Ridge (L2); MAP with Laplace prior = Lasso (L1)
- SGD: 1 sample per update (noisy). Mini-batch: B samples (balanced).
- Convex functions have a single global minimum. MSE is convex.
10. GATE DA Tips for ML Foundations
🎯 High-Frequency GATE Topics:
- Confusion matrix calculations (Precision, Recall, F1) — almost every year
- Linear regression: Normal equation & MSE computation
- K-Means: Step-by-step centroid updates with given data
- Decision trees: Entropy & Information Gain calculation
- Bias-Variance decomposition conceptual questions
- PCA: Eigenvalue problems, explained variance
- R² and Adjusted R² calculation
- Ridge vs Lasso conceptual differences
- Always check: does the question ask for MSE or RMSE? (RMSE = √MSE)
- Entropy is maximised when all classes are equally likely
- For NAT questions on metrics: compute step-by-step, don’t round intermediate results
- R² can be negative (model worse than mean prediction)
11. Algorithms at a Glance
| Algorithm | Type | Key Idea | Bias | Variance |
|---|---|---|---|---|
| Linear Regression | Supervised (Reg) | Minimise MSE, closed-form solution | High | Low |
| Logistic Regression | Supervised (Cls) | Sigmoid + cross-entropy | Medium | Low |
| Decision Tree | Supervised | Recursive splitting on best feature | Low | High |
| Random Forest | Supervised | Ensemble of bagged trees | Low | Medium |
| SVM | Supervised | Maximum margin hyperplane + kernels | Low | Medium |
| KNN | Supervised | Majority vote of K nearest neighbours | Low (small K) | High (small K) |
| Naive Bayes | Supervised (Cls) | Bayes + feature independence assumption | High | Low |
| K-Means | Unsupervised | Minimise within-cluster sum of squares | — | — |
| PCA | Unsupervised | Eigen-decomposition of covariance matrix | — | — |