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.112 min Read Activity
What Is Machine Learning?
A precise definition, and how it differs from ordinary programming
Interactive: build a spam detector
- 1.28 min Read
Machine Learning Terminology
Features, labels, samples, models, parameters, training and inference
Interactive: label the parts of a dataset
- 1.310 min Read Activity
Types of Machine Learning
Supervised, unsupervised, semi-supervised, self-supervised and reinforcement learning
Card sort: which type fits?
- 1.48 min Read
The Machine Learning Workflow
From problem to data to model to evaluation to deployment
Interactive: order the workflow
Chapter 2 Preparing Data
- 2.110 min Read Activity
Training, Validation and Test Sets
Why data is split, and how to split it fairly
Code: train_test_split with stratification
- 2.210 min Read Activity
Feature Scaling and Encoding
Standardisation, normalisation and one-hot encoding
Code: prepare a mixed dataset
x′ = (x − μ) / σ
- 2.312 min Read Activity
Feature Engineering and Selection
Creating useful features from raw data and keeping only those that help
Code: engineer features for delivery times
- 2.410 min Read Activity
Handling Imbalanced Data
Rare classes, resampling, class weights and threshold moving
Code: rebalance a fraud data set
Chapter 3 Regression
- 3.112 min Read Activity
Linear Regression
Fitting a straight line to predict a number
Interactive: drag the line, then fit it in code
ŷ = wx + b
- 3.28 min Read Activity
- 3.312 min Read Activity
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²
Chapter 4 Classification
- 4.110 min Read Activity
k-Nearest Neighbours
Classifying by the most similar examples
Interactive: move a point and watch the vote
- 4.212 min Read
- 4.310 min Read
Logistic Regression
Predicting a probability for a yes-or-no answer
Code: predict pass or fail
P = 1 / (1 + e^−z)
- 4.410 min Read Activity
- 4.512 min Read Activity
Support Vector Machines
The widest-margin boundary, support vectors and kernels for curved data
Code: linear and RBF kernels compared
- 4.612 min Read Activity
Random Forests and Ensembles
Combining many decision trees by voting and averaging
Code: one tree compared with a forest
- 4.712 min Read Activity
Gradient Boosting
Building trees one after another, each fixing the errors of the last
Code: error falling over boosting rounds
Chapter 5 Clustering
- 5.112 min Read Activity
- 5.210 min Read Activity
Hierarchical Clustering
Merging the closest groups step by step and reading a dendrogram
Code: cluster cities by climate
- 5.310 min Read Activity
DBSCAN: Density-Based Clustering
Finding clusters of any shape and flagging noise points
Code: DBSCAN on moon-shaped data
Chapter 6 Dimensionality Reduction and Patterns
- 6.112 min Read Activity
Principal Component Analysis
Compressing many features into a few components that keep most of the variation
Code: PCA on handwritten digits
- 6.212 min Read Activity
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)
- 6.310 min Read Activity
Anomaly Detection
Finding unusual cases with z-scores, the IQR rule and isolation forests
Code: flag suspicious transactions
Chapter 7 More Kinds of Learning
- 7.112 min Read Activity
Introduction to Time Series Forecasting
Trend, seasonality, moving averages, lag features and time-based validation
Code: forecast monthly sales
- 7.212 min Read Activity
Recommender Systems
Content-based filtering, collaborative filtering and similarity
Code: recommend films to a user
- 7.312 min Read Activity
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)]
Chapter 8 Evaluating Models
- 8.110 min Read
Accuracy and the Confusion Matrix
True and false positives and negatives
Code: build a confusion matrix
- 8.212 min Read
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)
- 8.310 min Read
Overfitting and Underfitting
Memorising compared with generalising, and how to spot each
Interactive: tree depth and test score
- 8.48 min Read Activity
- 8.510 min Read Activity
- 8.610 min Read Activity
Hyperparameter Tuning
Grid search and random search with cross-validation
Code: GridSearchCV on a forest
Chapter 9 Tools and Practice
- 9.115 min Read Activity
No-Code Machine Learning
Building and comparing models visually with a data-mining tool
Lab: classify the Iris dataset without code
- 9.212 min Read Activity
- 9.325 min Read Activity
- 9.425 min Read Activity
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)
- 9.515 min Read Activity