Advanced · module A1
Supervised Machine Learning in Depth
By the end: Derive, implement, evaluate and tune regression, classification and ensemble models, and choose the right one for a real problem
- Covers
- Every major supervised algorithm with its mathematics, implemented from scratch and with scikit-learn, then evaluated and tuned properly
- Contents
- 6 chapters, 27 topics
- Time
- About 7 hours
- Level
- Advanced
- Your progress
- 0 / 27
This module builds on Mathematics for AI, Machine Learning Foundations. We suggest looking at it first, but the choice is yours.
Chapter 1 The Supervised Learning Workflow
- 1.115 min Read Activity
The End-to-End Supervised Workflow
Problem framing, baselines, splitting, training, evaluation and iteration
Code: a complete workflow on real data
- 1.215 min Read Activity
Data Preprocessing
Scaling, encoding, imputing missing values and handling outliers
Code: a ColumnTransformer for mixed data
x′ = (x − μ) / σ
- 1.312 min Read Activity
Data Leakage and Validation Design
Train, validation and test sets, and the ways leakage creeps in
Code: catch three leakage bugs
- 1.412 min Read Activity
Machine Learning Pipelines
Chaining preprocessing and models so nothing leaks
Code: a scikit-learn Pipeline
Chapter 2 Regression
- 2.120 min Read Activity
Linear Regression and Least Squares
The model, the cost function and the normal equation
Code: fit from scratch with NumPy
w = (XᵀX)⁻¹Xᵀy
- 2.215 min Read Activity
Gradient Descent for Linear Regression
Deriving and running the update rule
Interactive: watch the line learn
w ← w − η·(2/n)Xᵀ(Xw − y)
- 2.312 min Read Activity
Multiple and Polynomial Regression
Many features, curved relationships and choosing the degree
Code: degree compared with validation error
ŷ = w₀ + w₁x + w₂x²
- 2.415 min Read Activity
Regularisation: Ridge, Lasso and Elastic Net
Penalising large weights to reduce overfitting
Interactive: change λ and watch the weights
J = MSE + λΣw² , J = MSE + λΣ|w|
- 2.510 min Read Activity
Regression Metrics
MAE, MSE, RMSE, R² and residual analysis
Code: residual plots
R² = 1 − SS_res / SS_tot
Chapter 3 Classification
- 3.120 min Read Activity
Logistic Regression
The sigmoid, log loss and the decision boundary
Code: from scratch, then scikit-learn
L = −[y log p + (1 − y) log(1 − p)]
- 3.212 min Read Activity
k-Nearest Neighbours and Distance Metrics
Choosing k, distance measures and the curse of dimensionality
Interactive: k and the decision boundary
d = √Σ(xᵢ − yᵢ)²
- 3.315 min Read Activity
Naive Bayes Classifiers
Gaussian, multinomial and Bernoulli variants, and Laplace smoothing
Code: a text classifier from scratch
P(c|x) ∝ P(c) Π P(xᵢ|c)
- 3.418 min Read Activity
Support Vector Machines and Kernels
Maximum margin, soft margins and the kernel trick
Interactive: linear and RBF kernels
min ½‖w‖² + CΣξᵢ
- 3.518 min Read Activity
Decision Trees
Gini, entropy, information gain, CART and pruning
Code: a tree from scratch
Gini = 1 − Σpₖ²
Chapter 4 Ensemble Methods
- 4.115 min Read Activity
Bagging and Random Forests
Bootstrap samples, feature randomness and out-of-bag error
Code: forest compared with a single tree
- 4.218 min Read Activity
Boosting: AdaBoost and Gradient Boosting
Learning from the previous model's mistakes
Interactive: boosting step by step
Fₘ = Fₘ₋₁ + η·hₘ
- 4.315 min Read Activity
XGBoost, LightGBM and CatBoost
Modern gradient boosting libraries and when to use each
Code: tune a gradient-boosted model
- 4.410 min Read Activity
Chapter 5 Evaluation and Tuning
- 5.112 min Read Activity
Classification Metrics in Depth
Confusion matrix, precision, recall, F1 and specificity
Code: metrics for every threshold
P = TP/(TP+FP) , R = TP/(TP+FN)
- 5.212 min Read Activity
- 5.315 min Read Activity
Imbalanced Data and Threshold Tuning
Resampling, class weights and choosing a threshold by cost
Code: fraud detection with 1 per cent positives
- 5.410 min Read Activity
Cross-Validation Strategies
k-fold, stratified, grouped and time-series splits
Code: compare strategies
- 5.512 min Read Activity
The Bias-Variance Trade-off
Decomposing error, learning curves and model complexity
Interactive: bias and variance by model size
Error = Bias² + Variance + Noise
- 5.615 min Read Activity
- 5.715 min Read Activity
Model Interpretability
Permutation importance, partial dependence and SHAP values
Code: explain a model's predictions
Chapter 6 Project
- 6.145 min Read Activity
Project: An End-to-End Tabular Prediction System
From raw data to a tuned, explained and documented model
Project notebook with a written report
- 6.220 min Read