Start Here: The Maths Behind Machine Learning

If you have decided to learn machine learning and immediately hit a wall of unfamiliar notation — vectors, gradients, sigmas — you are in the right place. This is the order we recommend working through the material on this site. It assumes GCSE-level algebra and nothing else.

You do not need all of this before you train your first model. Stages 1–3 are the maths; stages 4–6 are the machine learning that uses it. If you are impatient: read Stage 0, skim Stage 1, jump to Stage 4, and come back when a symbol stops you.
  1. 0

    Orientation

    Get your bearings

    Before any maths, it helps to know what a model actually is, and what the three broad families of machine learning are for.

  2. 1

    Foundations · Maths

    Linear algebra: how data is represented

    Every dataset you will ever load is a matrix. Every row is a vector. Almost all of the speed in modern machine learning comes from expressing operations on those objects instead of looping over them.

    1a · Vectors

    1b · Matrices

    1c · Where it pays off

  3. 2

    Foundations · Maths

    Calculus: how models improve

    Training is repeated small adjustments in whichever direction reduces error. Derivatives are how a model works out which direction that is. You need far less calculus than a maths degree demands — mostly derivatives and the chain rule.

    Trig derivatives appear less often in machine learning than in a calculus course, but if you need them: trig derivatives, sin, cos, tan, cot, csc. For approximating awkward functions: Taylor series and Maclaurin series.

  4. 3

    Foundations · Maths

    Probability and statistics: how you judge results

    Statistics is what stops you fooling yourself. It is the difference between a model that looks good on your screen and one that works on data it has never seen.

  5. 4

    Machine learning

    How a model actually learns

    This is where the maths turns into machine learning. A loss function scores how wrong the model is; gradient descent uses the derivative of that score to adjust the weights; activation functions let a network represent something other than a straight line.

    4a · Loss functions — scoring the error

    4b · Gradient descent — using the error

  6. 5

    Machine learning

    Evaluating a model honestly

    Accuracy is the most misleading number in machine learning. On a dataset where 99% of cases are negative, a model that always predicts “negative” is 99% accurate and completely useless. These pages explain what to look at instead.

    5a · Getting numbers you can trust

    5b · Reading the metrics

  7. 6

    Build it

    Build something

    Start with linear regression — you can work the whole thing out on paper. Then logistic regression, which uses nearly everything above: a dot product, a sigmoid, a cross-entropy loss and gradient descent.

Tools to use along the way

Every calculator on this site shows its working, so you can check an answer and see the steps that produced it.

Browse by subject

Scroll to Top