All courses

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. 1.1

    The End-to-End Supervised Workflow

    Problem framing, baselines, splitting, training, evaluation and iteration

    Code: a complete workflow on real data

    15 min Read Activity
  2. 1.2

    Data Preprocessing

    Scaling, encoding, imputing missing values and handling outliers

    Code: a ColumnTransformer for mixed data

    x′ = (x − μ) / σ

    15 min Read Activity
  3. 1.3

    Data Leakage and Validation Design

    Train, validation and test sets, and the ways leakage creeps in

    Code: catch three leakage bugs

    12 min Read Activity
  4. 1.4

    Machine Learning Pipelines

    Chaining preprocessing and models so nothing leaks

    Code: a scikit-learn Pipeline

    12 min Read Activity

Chapter 2 Regression

  1. 2.1

    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

    20 min Read Activity
  2. 2.2

    Gradient Descent for Linear Regression

    Deriving and running the update rule

    Interactive: watch the line learn

    w ← w − η·(2/n)Xᵀ(Xw − y)

    15 min Read Activity
  3. 2.3

    Multiple and Polynomial Regression

    Many features, curved relationships and choosing the degree

    Code: degree compared with validation error

    ŷ = w₀ + w₁x + w₂x²

    12 min Read Activity
  4. 2.4

    Regularisation: Ridge, Lasso and Elastic Net

    Penalising large weights to reduce overfitting

    Interactive: change λ and watch the weights

    J = MSE + λΣw² , J = MSE + λΣ|w|

    15 min Read Activity
  5. 2.5

    Regression Metrics

    MAE, MSE, RMSE, R² and residual analysis

    Code: residual plots

    R² = 1 − SS_res / SS_tot

    10 min Read Activity

Chapter 3 Classification

  1. 3.1

    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)]

    20 min Read Activity
  2. 3.2

    k-Nearest Neighbours and Distance Metrics

    Choosing k, distance measures and the curse of dimensionality

    Interactive: k and the decision boundary

    d = √Σ(xᵢ − yᵢ)²

    12 min Read Activity
  3. 3.3

    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)

    15 min Read Activity
  4. 3.4

    Support Vector Machines and Kernels

    Maximum margin, soft margins and the kernel trick

    Interactive: linear and RBF kernels

    min ½‖w‖² + CΣξᵢ

    18 min Read Activity
  5. 3.5

    Decision Trees

    Gini, entropy, information gain, CART and pruning

    Code: a tree from scratch

    Gini = 1 − Σpₖ²

    18 min Read Activity

Chapter 4 Ensemble Methods

  1. 4.1

    Bagging and Random Forests

    Bootstrap samples, feature randomness and out-of-bag error

    Code: forest compared with a single tree

    15 min Read Activity
  2. 4.2

    Boosting: AdaBoost and Gradient Boosting

    Learning from the previous model's mistakes

    Interactive: boosting step by step

    Fₘ = Fₘ₋₁ + η·hₘ

    18 min Read Activity
  3. 4.3

    XGBoost, LightGBM and CatBoost

    Modern gradient boosting libraries and when to use each

    Code: tune a gradient-boosted model

    15 min Read Activity
  4. 4.4

    Stacking and Voting Ensembles

    Combining different models

    Code: a stacked ensemble

    10 min Read Activity

Chapter 5 Evaluation and Tuning

  1. 5.1

    Classification Metrics in Depth

    Confusion matrix, precision, recall, F1 and specificity

    Code: metrics for every threshold

    P = TP/(TP+FP) , R = TP/(TP+FN)

    12 min Read Activity
  2. 5.2

    ROC-AUC and Precision-Recall Curves

    Comparing models across all thresholds

    Code: plot both curves

    12 min Read Activity
  3. 5.3

    Imbalanced Data and Threshold Tuning

    Resampling, class weights and choosing a threshold by cost

    Code: fraud detection with 1 per cent positives

    15 min Read Activity
  4. 5.4

    Cross-Validation Strategies

    k-fold, stratified, grouped and time-series splits

    Code: compare strategies

    10 min Read Activity
  5. 5.5

    The Bias-Variance Trade-off

    Decomposing error, learning curves and model complexity

    Interactive: bias and variance by model size

    Error = Bias² + Variance + Noise

    12 min Read Activity
  6. 5.6

    Hyperparameter Tuning

    Grid, random and Bayesian search

    Code: tune with Optuna

    15 min Read Activity
  7. 5.7

    Model Interpretability

    Permutation importance, partial dependence and SHAP values

    Code: explain a model's predictions

    15 min Read Activity

Chapter 6 Project

  1. 6.1

    Project: An End-to-End Tabular Prediction System

    From raw data to a tuned, explained and documented model

    Project notebook with a written report

    45 min Read Activity
  2. 6.2

    Module Review and Assessment

    Derivations, coding tasks and a scored quiz

    Graded assessment

    20 min Read