CyberFreezeDev Loading
  1. Home
  2. Blog
  3. How-to guides
  4. Maths for machine learning: what you actually need

How-to guides

Maths for machine learning: what you actually need

Machine learning uses four areas of maths, but you need far less of each than a university syllabus suggests. What each one does in practice, how much is enough for your role, and the free books and courses worth your time.

The formula for a definite integral raised on a grey grid surface
The formula for a definite integral raised on a grey grid surface

Machine learning uses four areas of maths: linear algebra to hold data and model weights as vectors and matrices, calculus to train a model by following gradients, and probability and statistics to judge how far you can trust a result. To build with today's libraries and LLM APIs you need school algebra, a working feel for vectors and matrices, and solid basic statistics. The derivations matter only if you train or design models yourself.

A pocket calculator and a pen on a sheet of handwritten notes on graph paper
Most of the maths in day to day machine learning work is arithmetic on tables of numbers, done by a library.

Which maths does machine learning use, and for what?

Area What it does in practice Enough to start
Linear algebra Rows of data as vectors, a dataset as a matrix, embeddings and similarity search, the weights inside a neural network layer Vectors, dot product, matrix multiplication, what a dimension is
Calculus Training: the model's weights move a little in the direction that reduces its error What a derivative and a gradient mean; the idea of the chain rule
Probability Model outputs as probabilities, decision thresholds, how an LLM samples its next word Conditional probability, distributions, expected value
Statistics Whether a model beats a simple baseline, how you split and test data, what an error figure means Mean, median, standard deviation, outliers, sampling

Google's Machine Learning Crash Course prerequisites set a similar bar: be comfortable with variables, linear equations, graphs of functions, histograms and means; know matrix multiplication; and treat calculus as optional for advanced topics.

Linear algebra: your data is a matrix

A customer record with 12 numeric columns is a vector of 12 numbers. Ten thousand customers make a matrix of 10,000 rows and 12 columns. A layer of a neural network takes an input vector and multiplies it by a matrix of weights. When a training script fails with a "shape mismatch" error, that is a linear algebra problem: two matrices whose sizes cannot be multiplied.

The place most teams meet linear algebra today is embeddings. An embedding model turns a sentence into a long vector of numbers, and sentences with similar meaning end up as vectors pointing in similar directions. Cosine similarity, a common score in document search and RAG systems, is a dot product divided by the two vectors' lengths. If you understand that one line, you understand what a vector database is ranking.

Model size is also linear algebra plus arithmetic: the parameter count times the bytes per weight gives the memory, as our post on how much VRAM an LLM needs works through.

Calculus: how a model learns

Training starts with a loss function, a number that says how wrong the model is on the training data. The gradient says, for every weight, which direction reduces the loss. Training repeats a small step in that direction many times over. That is gradient descent, and the size of each step is the learning rate.

You will rarely compute a derivative by hand. PyTorch's autograd computes gradients automatically for any computational graph, and scikit-learn hides the optimisation entirely. What you do need is the intuition: a learning rate that is too high makes the loss jump about, one that is too low makes training crawl, and a loss that falls on training data while rising on test data means the model is memorising.

Go deeper into calculus when you write a custom loss function, fine-tune models and need to debug unstable training, or read research papers.

Probability and statistics: the part people skip

In business projects this is the maths you use most, and the part self-taught learners most often skip.

  • Thresholds. A classifier that flags risky invoices gives a probability, not a yes or no. Where you set the cut-off is a business decision about the cost of a missed case against the cost of a false alarm.
  • Base rates. If 1 invoice in 1,000 is fraudulent, a model that says "not fraud" every time is 99.9 percent accurate and useless.
  • Averages and outliers. One very large order can drag the mean far from a typical order. The median and standard deviation tell you more.
  • Testing. Keep data the model never saw, compare against a simple baseline, and choose a measure that matches the cost of errors. Our glossary entry on model evaluation covers the common measures.

For LLM projects the same habits apply: a test set of real questions, a count of right and wrong answers, and an honest comparison before and after each change.

Five white dice on a red surface
Probability and statistics decide whether a model's result is good enough to act on, which makes them the most used maths in business projects.

How much maths is enough for your role?

What you build Maths you need
Apps on LLM APIs, RAG, automations Statistics for evaluation; vectors and cosine similarity for embeddings
Classical models with scikit-learn The above, plus loss, overfitting, regression and train and test splits
Training or fine-tuning neural networks The above, plus gradients, learning rates and matrix shapes
New model designs and research University level linear algebra, multivariable calculus and probability

The last row is real: Stanford's CS229 machine learning course expects multivariable calculus, linear algebra and probability at university level. Most working professionals never need that row. Learn the maths alongside a project, one gap at a time, rather than spending months on theory before writing any code.

Free sources worth your time

  • Mathematics for Machine Learning by Deisenroth, Faisal and Ong (Cambridge University Press, 2020). The authors keep the full PDF free online. Part I covers linear algebra, vector calculus, probability and optimisation; Part II applies them to regression, PCA and classification.
  • MIT OpenCourseWare 18.06 Linear Algebra with Gilbert Strang: free video lectures, problem sets with solutions and exams.
  • OpenIntro Statistics: a free PDF textbook covering probability, distributions, inference and regression.
  • Google's Machine Learning Crash Course: its prerequisites page lists exactly which algebra and statistics topics to revise first.

Learning it as a team

If several people in your company need the same grounding, it is quicker to learn on your own data than on textbook examples. Our AI training workshops are built on a team's own tasks, and the technical session covers calling model APIs, retrieval over company documents and testing output with an evaluation set. Book a consultation to plan one around your team.