Machine Learning
Machine learning (ML) is the study of algorithms that improve at a task through experience with data, rather than by following hand-written rules. In practice, you show a model examples, pick a way to measure its mistakes, and adjust it until the mistakes are small, and then you check that it still works on examples it has never seen.
These notes start from the basics of supervised learning and build up one model at a time. They begin with linear regression and the optimization that trains it, add regularization and a probabilistic reading of the same models, move on to classification, and end with kernel methods. A second track summarizes what it takes to run ML in production.
Learning path
The eleven chapters build on each other, so reading them in order works best. Chapters 3 to 9 all start from the same linear model, changing what it predicts and how it is trained.
Foundations
What it means for a machine to learn, and how to frame a learning problem.
How learning from data differs from following explicit instructions, the parts of an ML system, and the main kinds of learning.
- Learning from experience
- Supervised
- Unsupervised
- Reinforcement
Formulates a prediction task from labeled data, with inputs, targets, a hypothesis class and a loss to train against.
- Regression
- Hypothesis class
- Loss functions
- Over- vs underfitting
Regression and optimization
Fit a linear model, then learn how to train it and keep it from overfitting.
Works through the first model in full, from the linear hypothesis and the mean squared error to the matrix form that makes it compact.
- Weights & bias
- Mean squared error
- Matrix-vector form
- Normal equations
Minimizes a loss by following its gradient, and the variants that make this work on large datasets.
- Gradient descent
- Step size
- Newton's method
- SGD
Restricts the hypothesis class to improve generalization, and why L1 and L2 penalties behave so differently.
- Model complexity
- L1 vs L2
- Sparsity
- Constrained optimization
Probabilistic models
Read models as probability distributions over targets.
Revisits linear regression through probability and shows that the squared error comes from maximum likelihood under Gaussian noise.
- Frequentist vs Bayesian
- Gaussian distribution
- Maximum likelihood
- MSE from MLE
Models binary outcomes with a Bernoulli distribution and a sigmoid, and derives the cross-entropy loss.
- Bernoulli
- Sigmoid
- Cross-entropy
- Convexity
Extends logistic regression to many classes with the softmax, and justifies picking the most probable class.
- Softmax
- Multiclass cross-entropy
- MAP inference
- Expected risk
Shows that linear, logistic and Poisson regression share one template, made of a distribution, a linear predictor and a link function.
- Exponential family
- Link functions
- Canonical links
- Poisson regression
Generalization and beyond
Choose models that work on new data, and move past linear features.
Estimates how a model will do on unseen data and picks hyperparameters without leaking the test set.
- Train / validation / test
- Cross-validation
- Hyperparameters
- Data leakage
Predicts from similarity to representative examples, and uses kernels to get rich features without building them.
- Nearest neighbors
- Feature maps
- Kernel trick
- RBF prototypes
Designing ML systems
This shorter, more practical track is my summary of Designing Machine Learning Systems by Chip Huyen. It covers what happens around the model, from framing the problem and preparing the data to deploying the result. It doesn't depend on the chapters above, and each card shows the book chapter it covers.
Framing the problem
Decide whether ML is the right tool, and what the system has to achieve.
When ML is worth using, and how ML in production differs from ML in research.
- When to use ML
- Research vs production
Ties business goals to ML objectives and lays out the requirements every ML system has to meet.
- Business vs ML objectives
- Requirements
- Iterative process
- Mind vs data
Data
Move data around, label it and turn it into features.
A short tour of how data flows between services, through databases, requests and real-time transport.
- Modes of dataflow
- Pub/sub
- Message queues
How to sample, label and rebalance the data a model learns from.
- Sampling
- Labeling
- Class imbalance
- Data augmentation
Common feature operations, how data leakage sneaks in, and what makes a feature good.
- Learned vs engineered
- Feature operations
- Data leakage
Models in production
Pick, evaluate and ship a model.
Choosing and tracking models, scaling training, and evaluating them before they go live.
- Model selection
- Ensembles
- Experiment tracking
- Offline evaluation
How a trained model serves predictions, either in batch or online, and either on the device or in the cloud.
- Deployment myths
- Batch vs online
- Edge vs cloud
Beyond the fundamentals
- Next trackReinforcement Learning
Learning to make decisions by trial and error, from multi-armed bandits to policy gradients.
- BackgroundStatistics
The probability these notes build on, including random variables, distributions and expected values.
- InteractiveGradient descent playground
Change the step size and watch gradient descent converge, overshoot or diverge.
Before you start
You don't need prior ML experience, but these help:
- Some linear algebra, such as vectors, matrices and matrix products. From chapter 3 on, models and losses are written in matrix-vector form.
- Some calculus, in particular derivatives and gradients of functions of several variables, which is how models are trained by gradient descent.
- Basic probability, covering random variables, probability distributions and expected values. Chapters 6 to 9 treat models as probability distributions.
How to use these notes
Each chapter opens with a short list of what it covers, and many end with a recap quiz. Chapters marked Interactive also have examples you can play with.
About these notes
These notes are meant as an additional resource for students, not a replacement for the courses or the books. They summarize the material from the University of Alberta courses I took or helped teach:
- CMPUT 566: Machine Learning Essentials, taught by Professor Lili Mou;
- CMPUT 467/504: Machine Learning II, taught by Professor Martha White;
- CMPUT 267: Machine Learning I, for which I have served as a teaching assistant under Professor Dieter Büchler.
References
General references for ML as a whole.
Books
- Murphy, K. P. (2022)
Probabilistic Machine Learning: An Introduction. A broad, probability-first treatment of the models in these notes and many more. - Goodfellow, I., Bengio, Y., & Courville, A. (2016)
Deep Learning. Its early chapters review the linear algebra, probability and optimization these notes rely on. - Huyen, C. (2022)
Designing Machine Learning Systems. The book behind the second track.
Lecture notes
- Stanford - CS229: Machine Learning (2023)
Lecture Notes (PDF) by Professors Andrew Ng and Tengyu Ma. - University of Alberta - CMPUT 367: Basics of Machine Learning (2024)
Lecture Notes (PDF) by Professor Martha White. - University of Alberta - CMPUT 504: Machine Learning II (2025)
Lecture Notes (PDF) by Professor Martha White.