Prerequisites for machine learning and AI: the maths, statistics and Python you need
The prerequisites for machine learning: Python, basic linear algebra and calculus, and intro statistics and probability. Exact topics and a readiness test.
The prerequisites for machine learning are three skills: Python you can write without copying, a small amount of maths (vectors, matrices, derivatives and gradients, logarithms), and introductory statistics and probability (distributions, spread, conditional probability, and how to tell a real difference from noise). You do not need a maths degree, and you do not need to learn every topic before you start: you can learn much of the maths alongside your first models.
Below is what each prerequisite covers, why a model needs it, what deep learning and generative AI add on top, free resources for each, and a checklist to test whether you are ready.
What are the skills needed for machine learning?
| Skill | What you actually need | Why a model needs it |
|---|---|---|
| Python | Functions, lists, dictionaries, files, classes at a reading level | Every library, dataset and experiment is driven from Python |
| Data tools | NumPy arrays, pandas tables, a basic chart, the scikit-learn API | Data has to be loaded, cleaned and shaped before any model sees it |
| Linear algebra | Vectors, the dot product, matrices, the matrix–vector product | A dataset is a matrix; a linear model's predictions are one product |
| Calculus | Derivatives, the chain rule, partial derivatives, the gradient | Training lowers a loss by following its gradient |
| Statistics | Mean, median, variance, distributions, correlation, sampling | You need to understand the data before you trust a model built on it |
| Probability | Conditional probability, Bayes' theorem, expectation, likelihood | Classifiers output probabilities; log loss comes from likelihood |
Notice what is missing: proofs, integration techniques, abstract algebra, and most of a typical statistics syllabus. Those can matter for research, but they are not prerequisites for building and evaluating classical models.
Python: the prerequisite you cannot skip
Maths can be learned in parallel with your first model. Python cannot, because every exercise is written in it. You should be able to write a function, loop over a list, use a dictionary to count things, read a CSV file and handle an error. You should also be able to read a class well enough to understand model.fit(X, y) and model.coef_.
The free Python track is built for this: it teaches the language the way machine learning code uses it, from running your first code to the estimator pattern in objects and classes, where you write a tiny model class with fit and predict. For what to prioritise and what to skip, see Python for machine learning.
After the language, learn the four libraries in the Data Tools track: NumPy, pandas, Matplotlib and scikit-learn. The linear algebra in NumPy lesson in the NumPy module is a good bridge to the next section, because it writes the matrix maths of machine learning directly as code.
Math prerequisites for machine learning: linear algebra, calculus and probability
How much maths do you need for machine learning? Less than most people fear, but more than none. The SchoolWhool Maths track covers the set machine learning uses, each idea shown on a picture before the formula:
- Functions, logarithms and notation. Read
ŷᵢ = Σⱼ wⱼ xᵢⱼaloud in words. Know that a log turns a product into a sum, which is why likelihoods are computed as log-likelihoods. - Linear algebra: vectors. A row of data is a point and an arrow. The dot product measures alignment, and a weighted sum of features (a linear model's prediction) is a dot product.
- Linear algebra: matrices. A dataset is an
n × dmatrix. Every prediction at once is the productXw. The transpose, the inverse, and later eigenvectors and the SVD (behind PCA) all build on this. - Calculus: derivatives and the gradient. A derivative is a rate of change. A gradient points uphill, so stepping against it lowers the loss. That one sentence is gradient descent. The chain rule is how the gradient of a long computation is calculated, which is the core of training neural networks.
- Probability. Conditional probability, Bayes' theorem and likelihood, covered in the statistics section below.
The Maths lesson pages have parts and key terms to study, and a free account opens their quizzes. Derivatives: rate of change and the tangent has a free video, and the calculus and optimisation cheat sheet is free to read.
Here is most of that maths in ten lines of NumPy. It runs as written.
import numpy as np
X = np.array([[1.0, 2.0], [2.0, 0.5], [3.0, 1.5]]) # 3 samples, 2 features
y = np.array([5.0, 4.0, 7.5]) # the targets
w = np.zeros(2) # the weights, before training
for step in range(500):
y_hat = X @ w # every prediction: dot products
error = y_hat - y
loss = (error ** 2).mean() # mean squared error
grad = 2 * X.T @ error / len(y) # the gradient of the loss
w -= 0.05 * grad # one step of gradient descent
print("weights:", w.round(3), " loss:", round(loss, 4))
It prints weights of about [1.622 1.705] and a loss close to zero. If you can explain each commented line, you already have the linear algebra and calculus that the first half of a machine learning course uses. If you cannot yet, that is your list of things to learn. The free gradient descent lesson in the Machine Learning course walks through the idea with pictures.
What statistics and probability do you need?
Statistics is the prerequisite people underrate. A model is only as good as the data it learned from, and reading a test score correctly is a statistical question. The Statistics track covers this, and these modules are the core:
- Describing data: mean, median and mode; variance, standard deviation and IQR; histograms and density; correlation, confounding and causation; and who is (and is not) in the dataset, which explains why a random train/test split does not fix a biased sample. Its cheat sheet is free to read.
- Probability: conditional probability, independence and Bayes' theorem, the basis of every probabilistic classifier.
- Distributions and dependence: the normal distribution, z-scores and the 68–95–99.7 rule, which explain why features are standardised.
- Estimation: maximum likelihood, which connects directly to the log loss logistic regression minimises, and confidence intervals, so a test score comes with its uncertainty.
Hypothesis testing and information theory (entropy, entropy and cross-entropy) matter too, but they can wait until you meet them in a model. For the whole subject in a seven-step order, see statistics for data science and machine learning.
Prerequisites for deep learning and generative AI
Deep learning and generative AI build on the same three foundations. They do not replace them; they add a few ideas on top.
| Goal | Add to the list above |
|---|---|
| Train neural networks | The chain rule through many layers, matrix shapes, PyTorch tensors and a training loop |
| Understand how LLMs work | Tokens, embeddings, attention and the transformer, built on the deep learning list |
| Build applications on an LLM | Solid Python, JSON and APIs, embeddings and similarity, and a way to evaluate outputs |
- Deep learning starts where a first machine learning course ends: gradient descent, a test set, logistic regression and softmax. A neural network is logistic regression stacked in layers, and training it is the chain rule applied to every layer. See a neural network's forward and backward pass and matrix multiplication shapes, then the Deep Learning course.
- Generative AI has two paths. Understanding or training language models needs the deep learning list, because an LLM is a transformer. Building an application on top of one, such as retrieval-augmented generation (RAG) or an agent that calls tools, needs less maths and more engineering: tokens and context windows, cosine similarity for embeddings and measuring retrieval. The Generative AI course teaches both.
Statistics matters at every level. An LLM application still has to be evaluated on examples it was not built from, which is the same idea as a test set.
Free resources for each prerequisite
| Prerequisite | Free resource |
|---|---|
| Python | The official Python tutorial, or SchoolWhool's Python track, which starts from zero |
| Linear algebra, calculus | Mathematics for Machine Learning by Deisenroth, Faisal and Ong (Cambridge University Press), whose authors keep the PDF free; it covers linear algebra, vector calculus and probability |
| Statistics, probability | OpenIntro Statistics, a free PDF (an optional contribution is offered) covering data, probability, distributions, inference and regression |
| All three, as code | The SchoolWhool learning path: lesson parts and key terms are free to read, with no account |
These were checked on their official pages on 29 October 2026. Use a textbook as a reference when a lesson leaves a gap, not as a course to finish before you start.
Do I need all of this before I start?
No. A practical order is: Python first, then the data tools, then start machine learning while you learn the maths and statistics alongside it. Learn the derivative right before you meet gradient descent, the dot product right before linear regression, and Bayes' theorem right before Naive Bayes. Ideas stick better when they solve a problem you have just met.
The one thing to avoid is the opposite extreme: spending months on abstract maths without ever training a model. The where to start with machine learning post sets out a four-step order that interleaves the two.
A readiness checklist
You are ready to start a first machine learning course if you can do most of these:
- Write a Python function that takes a list and returns a dictionary of counts.
- Load a CSV with pandas, fill or drop missing values, and compute an average per group.
- Explain what
X.shape == (569, 30)means for a dataset. - Compute a dot product by hand for two short vectors.
- Say what the sign of a derivative tells you about a curve.
- Explain why the median can be a better "typical value" than the mean.
- Explain why correlation is not causation, with an example.
- Explain why a model must be scored on data it did not train on.
If two or three are shaky, start anyway and fill the gaps as they come up. If most are shaky, spend a few weeks on the Python and Statistics tracks first.
Common questions
Can I learn machine learning without maths?
You can train a model with a library and no maths, but you will struggle to tell why it fails or whether its score means anything. The maths you need is the short list above, and you can learn it alongside your first models.
Is linear algebra or calculus more important for machine learning?
For classical machine learning, linear algebra comes up first: every dataset is a matrix and every linear prediction is a dot product. Calculus matters as soon as you ask how a model is trained, because gradient descent follows the derivative. You need the basics of both, not a full course in either.
Do I need a degree to meet the prerequisites?
No. Every topic on this page is covered by free lessons and textbooks. Whether a particular job or programme requires a degree is a separate question that depends on the employer or institution.
How long does it take to learn the prerequisites?
It depends on where you start and how much time you have each week. Use the readiness checklist rather than a calendar: when you can do most of it, start a machine learning course.
Your next step
Start with whichever prerequisite is weakest: the Python track, the Statistics track or the Maths track. Lesson parts and key terms are free to read, and so are the free videos. A free account adds the quizzes and saves your progress, with no payment. When you want to see a whole model in code, read machine learning code in Python.
For the order to learn everything in, follow how to learn AI from scratch. To pick a course that matches your level, see the best machine learning course comparison.