Learn the skills
Math for Machine Learning: What You Need and How Deep to Go
By the AIJobDesk team · Updated
Machine learning uses four areas of math: linear algebra, calculus, probability and statistics. Applied roles like ML engineer and AI engineer need working intuition in all four, enough to read model code and debug training. Research roles need fluency, including proofs and optimization theory.
Machine learning uses four areas of math: linear algebra, calculus, probability and statistics. For applied roles like ML engineer or AI engineer you need working intuition in all four, enough to read model code, pick metrics and debug training. Research roles need real fluency, including proofs and optimization theory. Most people learn fastest by tying each concept to code.
Which math is used in machine learning?
Here's where each area shows up in real ML work:
| Math area | Where you use it | Example |
|---|---|---|
| Linear algebra | Data representation, model layers, embeddings | A batch of inputs times a weight matrix |
| Calculus | Training via gradients | Backpropagation uses the chain rule |
| Probability | Loss functions, uncertainty, generative models | Cross-entropy, sampling tokens from an LLM |
| Statistics | Evaluation, experiments, data understanding | Confidence intervals on an A/B test |
| Optimization | Making training work | Learning rate schedules, Adam |
You don't need all of it on day one. You need enough to keep moving through the machine learning roadmap, and you deepen it as models demand.
Linear algebra for machine learning
Linear algebra is the language of data and models. A dataset is a matrix; a neural network layer is a matrix multiplication followed by a nonlinear function; an embedding is a vector.
What to learn:
- Vectors, matrices and tensors; shapes and dimensions.
- Matrix multiplication and why shapes must line up.
- Dot products and cosine similarity (the basis of vector search and attention).
- Transpose, inverse, identity matrix.
- Linear independence, rank and span, at an intuitive level.
- Eigenvalues and eigenvectors (used in PCA).
- Singular value decomposition (used in dimensionality reduction and low-rank methods like LoRA).
How deep to go: for applied work, be able to predict the shape of any tensor in a model and explain what a dot product measures. Shape errors are the most common bug in deep learning code.
Try this: compute cosine similarity between word embeddings in NumPy, then implement PCA with an eigendecomposition and compare it with scikit-learn's.
Calculus for machine learning
Training a model means adjusting parameters to reduce a loss. Calculus tells you which direction to move.
What to learn:
- Derivatives and what they mean: rate of change, slope.
- Partial derivatives and gradients for functions of many variables.
- The chain rule, which is the whole idea behind backpropagation.
- Common derivatives: polynomials, exponentials, logs, sigmoid, ReLU.
- Gradient descent and how the learning rate affects it.
How deep to go: be able to derive the gradient for linear regression with mean squared error and explain backpropagation through a two-layer network on a whiteboard. You won't compute gradients by hand at work, since frameworks like PyTorch do it automatically, but interviewers ask, and the intuition helps you debug exploding or vanishing gradients.
Try this: implement logistic regression with gradient descent from scratch, then compare your gradients to PyTorch's autograd.
Probability for machine learning
Many models are probabilistic at heart. Classification outputs probabilities, language models sample from distributions, and loss functions come from probability.
What to learn:
- Random variables, probability distributions (Bernoulli, binomial, normal, categorical).
- Conditional probability and Bayes' rule.
- Expectation, variance and covariance.
- Independence and the idea of i.i.d. data.
- Maximum likelihood estimation, which explains why we use cross-entropy and squared error.
- Entropy and KL divergence, used in loss functions and in comparing distributions.
How deep to go: be able to explain why cross-entropy is the right loss for classification and how temperature changes sampling in a language model.
Statistics for machine learning
Statistics is how you know whether a model actually works and whether a result is real.
What to learn:
- Descriptive statistics: mean, median, variance, percentiles.
- Sampling and the central limit theorem.
- Confidence intervals and hypothesis tests.
- p-values, statistical power and sample size.
- Bias and variance; correlation versus causation.
- A/B testing basics.
How deep to go: data scientists need the most here. Expect interview questions on experiment design, as covered in our data science interview questions. ML engineers need enough to evaluate models honestly and avoid fooling themselves with a lucky test split.
Optimization: the math that makes training work
Optimization ties calculus and linear algebra together. Every training run is an optimization problem: find parameters that minimize a loss.
What to learn:
- Convex versus non-convex functions, and why neural network losses are non-convex.
- Stochastic and mini-batch gradient descent.
- Momentum and adaptive methods such as Adam and AdamW.
- Learning rate schedules: warmup, cosine decay.
- Regularization as a change to the loss (L1, L2, weight decay).
- Constrained optimization and Lagrange multipliers, at an intuitive level (used in SVMs).
How deep to go: for applied work, understand why a too-high learning rate makes loss explode and why warmup helps large models. For research, go further into convergence theory and second-order methods.
What does ML math look like in practice?
Here's one example that uses all four areas. In logistic regression for spam detection:
- Linear algebra: each email becomes a feature vector; the model computes a dot product with a weight vector.
- Probability: a sigmoid turns that score into the probability the email is spam, and the loss is the negative log-likelihood.
- Calculus: gradient descent uses the derivative of that loss to update the weights.
- Statistics: you check precision and recall on a held-out set and put a confidence interval around them.
If you can explain every line of that example, you have enough math to start applied ML work.
How much math do you need for each AI role?
| Role | Linear algebra | Calculus | Probability and stats | Proofs and theory |
|---|---|---|---|---|
| AI engineer (building with LLMs) | Basic | Basic | Moderate | Rarely |
| Machine learning engineer | Moderate | Moderate | Moderate | Rarely |
| Data scientist | Basic to moderate | Basic | Strong | Sometimes |
| Research engineer | Strong | Strong | Strong | Sometimes |
| AI research scientist | Strong | Strong | Strong | Often |
| Quantitative researcher | Strong | Strong | Very strong | Often |
If you're aiming for an AI engineer role, building applications on top of existing models, you can start working with intuition-level math and deepen it on the job. Research roles expect the full set from the start.
What's the best way to learn math for machine learning?
Learning math in isolation for months is the most common mistake. A better approach:
- Refresh foundations fast. Use Khan Academy for algebra, functions and basic probability if you're rusty.
- Build intuition visually. Watch 3Blue1Brown's Essence of Linear Algebra and Essence of Calculus series.
- Pick one structured resource. The free Mathematics for Machine Learning book by Deisenroth, Faisal and Ong, or the Imperial College specialization on Coursera.
- Implement everything. For each concept, write 20 lines of NumPy that use it. Plot results.
- Learn just in time. When a model uses a concept you don't know, stop and learn it then.
- Go deeper only if your target role needs it. Strang's MIT linear algebra course and a probability textbook are good next steps for research-track learners.
Python is the tool for all of this. If you're new to it, start with our guide to Python for AI.
A realistic math study plan
For someone with high school math, studying alongside ML coursework:
- Weeks 1 to 2: algebra and functions refresher; vectors and matrices.
- Weeks 3 to 4: matrix multiplication, dot products, implement in NumPy.
- Weeks 5 to 6: derivatives, chain rule, gradient descent from scratch.
- Weeks 7 to 8: probability, distributions, Bayes' rule.
- Weeks 9 to 10: statistics, confidence intervals, hypothesis testing.
- Ongoing: eigenvectors, SVD, entropy and KL divergence as models require them.
That's enough to work through classical ML and start deep learning. Strong math students can compress it to a few weeks of review.
Mistakes to avoid
- Waiting until you've mastered math to start ML. You'll never feel ready.
- Memorizing formulas without intuition. You should be able to say what a gradient means in words.
- Skipping statistics. It's the area that most often catches out engineers in interviews.
- Going too deep too early. Measure theory isn't required for applied work.
- Never coding the math. Implementation turns abstract ideas into something you remember.
Next step
If you're worried about difficulty, our post on whether machine learning is hard to learn gives an honest picture. Strong in math already? See AI jobs for mathematicians for roles where that background is an advantage, or browse AI research scientist jobs, where deep math is part of the daily work.
Ready to apply? Browse AI Research Scientist jobs
Frequently asked questions
- Is math needed for machine learning?
- Yes, but less than many people fear for applied work. You need enough linear algebra, calculus, probability and statistics to understand what models do, choose the right metric, read documentation and debug training. Libraries handle the computation. Research roles and work on new architectures or training methods need much deeper math.
- How much math do you need for machine learning?
- For applied ML and AI engineering, roughly first-year university level: matrix operations, derivatives and the chain rule, basic probability distributions and hypothesis testing, all at an intuitive level. For data science, add more statistics and experiment design. For research, add multivariable calculus, optimization, linear algebra theory and probability at graduate level.
- Is Mathematics for Machine Learning a good book?
- Mathematics for Machine Learning by Deisenroth, Faisal and Ong is widely recommended and its authors make a free PDF available. It's rigorous and well organized, covering linear algebra, calculus, probability and optimization, then applying them to classic models. Beginners sometimes find it dense, so pair it with visual resources such as 3Blue1Brown's videos.
- What math is most important for deep learning?
- Linear algebra and calculus matter most. Neural networks are chains of matrix multiplications and nonlinear functions, and training uses gradients computed with the chain rule. Probability matters for loss functions like cross-entropy, for generative models and for understanding sampling in language models. Optimization intuition helps with learning rates and training stability.
- Can I learn machine learning if I'm bad at math?
- Usually yes, if you're willing to rebuild foundations steadily. Many people who struggled with math in school find it easier when it's attached to code they can run. Learn each concept by implementing it in NumPy, plotting it and seeing how changing it affects a model. Start with applied roles, which need intuition more than proofs.
- What's the best course for math for machine learning?
- Popular options include the Mathematics for Machine Learning specialization from Imperial College London on Coursera, Khan Academy for refreshers, 3Blue1Brown's Essence of Linear Algebra and Essence of Calculus series for intuition, and MIT OpenCourseWare's linear algebra course by Gilbert Strang for depth. Pick one main resource and use the others to fill gaps.