Maths for Machine Learning: What to Learn and How Deep to Go
Quick answer
A practical guide to the maths machine learning uses, how deep to go for your role, and a hand-traced gradient descent example that ties it together.
The maths for machine learning sits in four areas: linear algebra, calculus, probability and statistics, and optimisation. To start building models you need a working grasp of vectors and matrices, the idea of a derivative, means and distributions, and how gradient descent reduces error. Deeper theory matters later, and how much depends on whether you apply models, engineer them or research them.
Key takeaways
- Class 11 and 12 maths (functions, matrices, differentiation, probability) is a sufficient base to begin. You are revising and extending, not starting from zero.
- Learn maths alongside code. One concept, one small NumPy experiment, then move on.
- Google's Machine Learning Crash Course lists calculus as optional for its advanced topics and says you will not have to calculate derivatives yourself.
- If you understand the short gradient descent example on this page, you understand the core of how most models are trained.
On this page:
- How much maths do you need for your goal?
- What linear algebra should you learn?
- How much calculus is enough?
- Which probability and statistics topics matter?
- How do the pieces meet in gradient descent?
- What is a realistic study plan?
- What can you safely postpone?
- Frequently asked questions
How much maths do you need for your goal?
It depends on what you will do with models. Find your column and aim for that depth first.
| Area | Using ML libraries on business data | ML or AI engineer | Research or core modelling |
|---|---|---|---|
| Linear algebra | Vectors, matrices, shapes | Matrix multiplication, dot product, norms, basic decompositions | Eigen-decomposition, SVD, vector spaces in depth |
| Calculus | Slope as rate of change | Partial derivatives, chain rule, gradients | Vector calculus, Jacobians, Hessians |
| Probability and statistics | Mean, variance, distributions, sampling | Conditional probability, Bayes, likelihood, hypothesis tests | Estimation theory, Bayesian inference |
| Optimisation | What a loss function is | Gradient descent, learning rate, regularisation | Convexity, constrained optimisation |
These four areas are not an arbitrary list. The textbook Mathematics for Machine Learning by Deisenroth, Faisal and Ong (Cambridge University Press, 2020) builds its foundations part from linear algebra, analytic geometry, matrix decompositions, vector calculus, probability and continuous optimisation, and the authors keep a free PDF on the book's site.
At the entry end, Google's Machine Learning Crash Course prerequisites ask for comfort with variables, linear equations, graphs of functions, histograms and statistical means, plus matrix multiplication. That is a low bar, and it is deliberate.
What linear algebra should you learn?
Learn to see data as vectors and models as matrix operations. This is the area you will use every single day, because every dataset is a matrix and every prediction is some form of multiplication.
The short list
- Vectors: a row of your data. A flat described by [area, bedrooms, age] is a vector in three dimensions.
- Dot product: multiply matching entries and add. A linear model's prediction is the dot product of weights and features.
- Matrix multiplication and shapes: an (m, n) matrix times an (n, p) matrix gives (m, p). Most beginner bugs are shape mismatches.
- Norm and distance: the length of a vector. k-nearest neighbours and clustering depend on it.
- Later: eigenvalues and SVD, which sit behind PCA and recommendation methods.
import numpy as np
features = np.array([1, 2, 3])
weights = np.array([4, 5, 6])
print(features @ weights) # 32 = 1*4 + 2*5 + 3*6
print(np.linalg.norm(np.array([3, 4]))) # 5.0 length of the vector (3, 4)
For a full free course, MIT OpenCourseWare hosts Linear Algebra (18.06SC) taught by Prof. Gilbert Strang, with lecture videos, problem sets and solutions. To practise the array side, use the NumPy tutorial for beginners.
How much calculus is enough?
Enough to know what a derivative means and how the chain rule passes it through layers. You will rarely differentiate by hand, since libraries do it automatically, but you must be able to read what they are doing.
- Derivative: how much the output changes when the input changes a little. For a loss function, it tells you which way to nudge a weight.
- Partial derivative: the same idea when there are many weights. Change one, hold the rest fixed.
- Gradient: all the partial derivatives collected in a vector. It points in the direction of steepest increase, so training moves the opposite way.
- Chain rule: the derivative of a function of a function. Backpropagation in neural networks is the chain rule applied layer by layer.
Google's prerequisites page lists exactly these four items under calculus, marks them optional for advanced topics, and adds that you will not have to actually calculate derivatives in the course. Integration, by contrast, appears far less in day-to-day ML work, mostly inside probability.
Which probability and statistics topics matter?
The ones that let you reason about uncertainty and judge a model's results. Models output probabilities, data is a sample, and every evaluation metric is a statistic.
- Mean, median, variance and standard deviation.
- Conditional probability and Bayes' rule, the logic behind Naive Bayes and behind interpreting any classifier's alerts.
- Common distributions: normal, binomial, uniform.
- Likelihood: how probable the observed data is under a model. Many loss functions, including cross-entropy, come from maximising it.
- Sampling, confidence intervals and hypothesis tests, for comparing two models honestly.
Each of these is worked through with numbers in statistics for data science.
How do the pieces meet in gradient descent?
Gradient descent uses a derivative (calculus) of an average error (statistics) over data stored as arrays (linear algebra) to improve weights step by step (optimisation). Google's course defines gradient descent as a technique that "iteratively finds the weights and bias that produce the model with the lowest loss".
Here is the whole idea with one weight. The data follows y = 2x, and the model must discover the 2.
xs = [1, 2, 3]
ys = [2, 4, 6] # true rule: y = 2x
w, lr = 0.0, 0.05 # starting weight, learning rate
for step in range(1, 6):
grad = sum(2 * (w * x - y) * x for x, y in zip(xs, ys)) / len(xs)
w = w - lr * grad
loss = sum((w * x - y) ** 2 for x, y in zip(xs, ys)) / len(xs)
print(step, round(grad, 3), round(w, 3), round(loss, 3))
1 -18.667 0.933 5.31
2 -9.956 1.431 1.51
3 -5.31 1.697 0.43
4 -2.832 1.838 0.122
5 -1.51 1.914 0.035
Trace step 1 by hand
The loss is the mean of (w*x - y) squared. Its derivative with respect to w is the mean of 2*(w*x - y)*x. At w = 0 that is 2 * (-2*1 - 4*2 - 6*3) / 3 = -18.667. The gradient is negative, so increasing w lowers the loss. New w = 0 - 0.05 * (-18.667) = 0.933. Each step repeats this, and w climbs towards 2 while the loss shrinks.
Try two experiments. Set lr = 0.3 and watch w overshoot and the loss blow up. Set lr = 0.001 and watch it crawl. That is the learning rate trade-off, felt instead of memorised. Interviewers like this trace, as the list of machine learning interview questions for freshers shows.
What is a realistic study plan?
Study in short loops of concept, code and application, and let your starting point set the order. Two common situations:
A second-year BTech or BCA student
Your school maths is recent. Spend most of your time on linear algebra with NumPy and on probability, then implement linear regression from scratch. Use semester maths courses as revision, and connect each topic to a model.
A working professional several years away from maths
Begin with a refresher on functions, graphs and logarithms. Then statistics first, because it pays off at work immediately. Add vectors and matrices next, and calculus last, at the intuition level. Train a model with a library early so the maths has something to attach to.
In both cases, a sensible sequence is:
- Descriptive statistics and probability basics.
- Vectors, matrices, dot product, shapes.
- Derivatives, partial derivatives, chain rule.
- Gradient descent and loss functions, in code.
- One project from these machine learning project ideas for beginners, noting where each concept showed up.
What can you safely postpone?
Postpone anything you cannot yet connect to a model. Formal proofs, measure theory, advanced integration techniques, tensor calculus and convex analysis are valuable for research, and unnecessary for a first job building and evaluating models.
A useful rule: when a concept appears in a paper, a library's documentation or an interview question you could not answer, that is the signal to learn it. Until then, breadth with working code beats depth without it. If you are moving from development, the guide on going from software engineer to machine learning engineer shows where the maths fits among the other skills.
Next step: run the gradient descent snippet, change the data to y = 3x + 1 and add a bias term yourself. If you want the maths taught in context with projects, the Artificial Intelligence and Machine Learning programme from Vishlesan i-Hub, IIT Patna runs for 08 months, and the Certification in AI & ML (Launchpad) from the same institution is a 12-week starting point.
Frequently asked questions
Can I learn machine learning without being good at maths?
You can start. Libraries handle the calculations, and school-level algebra is enough to train your first models. To debug models, choose methods and clear interviews, you will need to build up linear algebra, probability and basic calculus as you go.
Is Class 12 maths enough for machine learning?
It is a sufficient starting base. Class 12 covers matrices, differentiation and probability, which map directly to the core areas. You will need to extend them to vectors in many dimensions, partial derivatives and distributions.
Which is more important for machine learning, linear algebra or calculus?
Linear algebra is used more often in daily work because all data and model operations are matrix operations. Calculus explains how training works. For most practitioners, linear algebra and statistics deserve more time than calculus.
Do I need maths to work with large language models and generative AI?
Application work with model APIs needs little maths beyond vectors and similarity for embeddings and basic probability for sampling settings. Training or fine-tuning models, or reading research papers, needs the full set covered here.
How long does it take to learn the maths for machine learning?
It varies with your background and weekly hours. Treat it as an ongoing track beside coding, not a phase to finish first. Aim for working understanding of the core list, then deepen topics when a project or paper requires them.