All courses

Intermediate · module I5 · Sublevel Intermediate

Machine Learning Foundations

By the end: Frame a problem as regression, classification or clustering, train and evaluate a model, and diagnose overfitting

Covers
The machine learning workflow and the core algorithms, trained and evaluated with scikit-learn and no-code tools
Contents
9 chapters, 38 topics
Time
About 7 hours
Level
Intermediate
Your progress
0 / 38

This module builds on Working with Data: NumPy, pandas, SQL and Visualisation, Mathematics for AI. We suggest looking at it first, but the choice is yours.

Chapter 1 Foundations

  1. 1.1

    What Is Machine Learning?

    A precise definition, and how it differs from ordinary programming

    Interactive: build a spam detector

    12 min Read Activity
  2. 1.2

    Machine Learning Terminology

    Features, labels, samples, models, parameters, training and inference

    Interactive: label the parts of a dataset

    8 min Read
  3. 1.3

    Types of Machine Learning

    Supervised, unsupervised, semi-supervised, self-supervised and reinforcement learning

    Card sort: which type fits?

    10 min Read Activity
  4. 1.4

    The Machine Learning Workflow

    From problem to data to model to evaluation to deployment

    Interactive: order the workflow

    8 min Read

Chapter 2 Preparing Data

  1. 2.1

    Training, Validation and Test Sets

    Why data is split, and how to split it fairly

    Code: train_test_split with stratification

    10 min Read Activity
  2. 2.2

    Feature Scaling and Encoding

    Standardisation, normalisation and one-hot encoding

    Code: prepare a mixed dataset

    x′ = (x − μ) / σ

    10 min Read Activity
  3. 2.3

    Feature Engineering and Selection

    Creating useful features from raw data and keeping only those that help

    Code: engineer features for delivery times

    12 min Read Activity
  4. 2.4

    Handling Imbalanced Data

    Rare classes, resampling, class weights and threshold moving

    Code: rebalance a fraud data set

    10 min Read Activity

Chapter 3 Regression

  1. 3.1

    Linear Regression

    Fitting a straight line to predict a number

    Interactive: drag the line, then fit it in code

    ŷ = wx + b

    12 min Read Activity
  2. 3.2

    Measuring Regression Error

    MAE, MSE and RMSE

    Code: compare two models

    MSE = Σ(y − ŷ)² / n

    8 min Read Activity
  3. 3.3

    Polynomial Regression and Regularisation

    Curved fits, and ridge and lasso penalties that stop a model from overfitting

    Code: fit curves of different degrees

    Loss = MSE + λΣw²

    12 min Read Activity

Chapter 4 Classification

  1. 4.1

    k-Nearest Neighbours

    Classifying by the most similar examples

    Interactive: move a point and watch the vote

    10 min Read Activity
  2. 4.2

    Decision Trees

    Classifying with a series of learned questions

    Interactive: grow a tree

    12 min Read
  3. 4.3

    Logistic Regression

    Predicting a probability for a yes-or-no answer

    Code: predict pass or fail

    P = 1 / (1 + e^−z)

    10 min Read
  4. 4.4

    Naive Bayes

    Classifying text with probabilities

    Code: classify messages

    10 min Read Activity
  5. 4.5

    Support Vector Machines

    The widest-margin boundary, support vectors and kernels for curved data

    Code: linear and RBF kernels compared

    12 min Read Activity
  6. 4.6

    Random Forests and Ensembles

    Combining many decision trees by voting and averaging

    Code: one tree compared with a forest

    12 min Read Activity
  7. 4.7

    Gradient Boosting

    Building trees one after another, each fixing the errors of the last

    Code: error falling over boosting rounds

    12 min Read Activity

Chapter 5 Clustering

  1. 5.1

    k-Means Clustering

    Finding groups in unlabelled data

    Interactive: watch centroids move

    12 min Read Activity
  2. 5.2

    Hierarchical Clustering

    Merging the closest groups step by step and reading a dendrogram

    Code: cluster cities by climate

    10 min Read Activity
  3. 5.3

    DBSCAN: Density-Based Clustering

    Finding clusters of any shape and flagging noise points

    Code: DBSCAN on moon-shaped data

    10 min Read Activity

Chapter 6 Dimensionality Reduction and Patterns

  1. 6.1

    Principal Component Analysis

    Compressing many features into a few components that keep most of the variation

    Code: PCA on handwritten digits

    12 min Read Activity
  2. 6.2

    Association Rules and Market Basket Analysis

    Support, confidence, lift and the Apriori algorithm

    Code: find rules in shop baskets

    lift = confidence(A→B) / support(B)

    12 min Read Activity
  3. 6.3

    Anomaly Detection

    Finding unusual cases with z-scores, the IQR rule and isolation forests

    Code: flag suspicious transactions

    10 min Read Activity

Chapter 7 More Kinds of Learning

  1. 7.1

    Introduction to Time Series Forecasting

    Trend, seasonality, moving averages, lag features and time-based validation

    Code: forecast monthly sales

    12 min Read Activity
  2. 7.2

    Recommender Systems

    Content-based filtering, collaborative filtering and similarity

    Code: recommend films to a user

    12 min Read Activity
  3. 7.3

    Introduction to Reinforcement Learning

    Agents, states, actions, rewards and learning by trial and error with Q-learning

    Interactive: reward maze

    Q(s,a) ← Q(s,a) + α[r + γ·max Q(s′,a′) − Q(s,a)]

    12 min Read Activity

Chapter 8 Evaluating Models

  1. 8.1

    Accuracy and the Confusion Matrix

    True and false positives and negatives

    Code: build a confusion matrix

    10 min Read
  2. 8.2

    Precision, Recall and F1 Score

    Choosing the right metric for the cost of each error

    Code: compare metrics on imbalanced data

    F1 = 2PR / (P + R)

    12 min Read
  3. 8.3

    Overfitting and Underfitting

    Memorising compared with generalising, and how to spot each

    Interactive: tree depth and test score

    10 min Read
  4. 8.4

    Cross-Validation

    A fairer estimate using several splits

    Code: five-fold cross-validation

    8 min Read Activity
  5. 8.5

    ROC Curves and AUC

    Comparing classifiers across every decision threshold

    Code: draw a ROC curve

    10 min Read Activity
  6. 8.6

    Hyperparameter Tuning

    Grid search and random search with cross-validation

    Code: GridSearchCV on a forest

    10 min Read Activity

Chapter 9 Tools and Practice

  1. 9.1

    No-Code Machine Learning

    Building and comparing models visually with a data-mining tool

    Lab: classify the Iris dataset without code

    15 min Read Activity
  2. 9.2

    The scikit-learn Workflow

    fit, predict, score and pipelines

    Code: a complete pipeline

    12 min Read Activity
  3. 9.3

    Project: Predict House Prices

    An end-to-end regression project

    Project notebook

    25 min Read Activity
  4. 9.4

    Testing an ML Prediction Pipeline

    Contract, behavioural and regression tests for valid, missing, unseen and malformed inputs, held-out evaluation and monitoring

    Lab: write regression tests for a house-price predictor

    MAE = average of abs(actual − predicted)

    25 min Read Activity
  5. 9.5

    Module Review and Assessment

    Coding exercises and a scored quiz

    Graded project checkpoints

    15 min Read Activity