Topics

Mathematics matters in machine learning because models are mathematical objects. Inputs are represented in vector spaces, parameters are estimated from finite samples, predictions are evaluated through loss functions, and training is formulated as optimization. The relevant question is therefore not whether one must "know all the mathematics" before using machine learning. It is which mathematical structures determine the behavior of the model being used.
A useful foundation consists of linear algebra, calculus, probability, statistics, and optimization. Each answers a different question.
Linear algebra: representation and geometry
A dataset with $n$ observations and $p$ features is often represented as a matrix
Linear algebra provides the language for transformations, projections, decompositions, similarity, and conditioning. In linear regression,
the geometry of the columns of $X$ determines identifiability, collinearity, and numerical stability.
Singular value decomposition,
reveals rank, principal directions, and ill-conditioning. PCA, least squares, low-rank approximation, embeddings, and many numerical solvers are best understood through this geometry.
In neural networks, affine transformations such as
are repeated layer by layer. Tensors generalize the same ideas to higher-dimensional arrays.
Calculus: sensitivity and local change
Calculus enters when model outputs or losses change smoothly with parameters. If a loss is
the gradient
describes local sensitivity to parameter changes.
Gradient-based optimization uses updates such as
Backpropagation is repeated application of the chain rule through a computational graph. The important concept is not that neural networks "use calculus," but that differentiability allows efficient computation of parameter sensitivities.
Second-order information, Hessians, curvature, and automatic differentiation become relevant when optimization speed, uncertainty, or local geometry matter.
Probability: uncertainty and generative assumptions
Probability describes random variables, conditional distributions, dependence, and uncertainty. A classification model may estimate
while a Bayesian model combines a likelihood and prior through
Probability also clarifies that uncertainty has several sources: irreducible outcome variation, measurement noise, parameter uncertainty, latent variables, and distribution shift.
A model that outputs a probability is making a stronger claim than a model that only ranks observations. Calibration matters whenever those numbers are interpreted as risks.
Statistics: learning from finite data
Statistics connects models to samples. Estimation, sampling distributions, bias, variance, confidence intervals, hypothesis tests, causal identification, and validation all live here.
The distinction between empirical and population quantities is central. A model minimizes an empirical loss such as
but the quantity of interest is usually future or population risk
The gap between the two is the generalization problem.
Statistics also determines whether a result is descriptive, predictive, or causal. No amount of optimization converts a confounded observational association into a causal effect.
Optimization: fitting under constraints
Training is often written as
The objective $L$ encodes fit, while $\Omega$ imposes structure such as shrinkage or sparsity.
Convex problems have useful global properties. Non-convex problems, including deep neural networks, require different reasoning about initialization, optimization dynamics, local geometry, and empirical performance.
Hyperparameter tuning is not the same thing as optimization of model parameters. Hyperparameters must usually be selected through a validation design, which makes them part of the statistical workflow.
Numerical analysis is often the missing layer
A mathematically correct formula can still be implemented badly. Explicit matrix inversion, unstable subtraction, poor scaling, and ill-conditioned systems can produce unreliable computation.
For example, solving
by explicitly computing $(X^\top X)^{-1}$ is usually inferior to a QR or SVD-based least-squares solver.
Understanding floating-point arithmetic, conditioning, convergence tolerances, and stable algorithms is therefore as important as symbolic derivation in production scientific code.
Logic and set theory are supporting tools, not the core of neural networks
Set theory and logic are fundamental to mathematics and computer science, but it is misleading to suggest that modern neural networks work by directly combining Boolean AND, OR, and NOT operations. Neural units generally apply affine transformations and nonlinear activation functions.
Formal logic becomes directly important in symbolic reasoning, verification, databases, knowledge representation, and rule-based systems. Its role should be stated precisely rather than used as a vague foundation claim.
How much mathematics is enough?
The answer depends on the task.
A practitioner training standard models needs enough mathematics to understand assumptions, failure modes, diagnostics, and evaluation. Someone developing new optimization methods, probabilistic models, or theoretical guarantees needs substantially more.
The useful test is practical: can you explain why the method should work, when it can fail, what the output means, and which assumptions are being made?
Conclusion
Mathematics is not valuable because machine learning needs a ceremonial foundation. It is valuable because it exposes structure.
Linear algebra explains representation and geometry. Calculus explains sensitivity. Probability formalizes uncertainty. Statistics connects finite data to population claims. Optimization determines how parameters are fitted. Numerical analysis determines whether the implementation is stable.
Once these roles are clear, mathematical study becomes much more useful than memorizing formulas in isolation.
References
- Bishop, C. M. (2006). Pattern Recognition and Machine Learning. Springer.
- Boyd, S., & Vandenberghe, L. (2004). Convex Optimization. Cambridge University Press.
- Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning. Springer.
- Strang, G. (2019). Linear Algebra and Learning from Data. Wellesley-Cambridge Press.
Embed interactive plots, widgets, and demos using <figure>, <iframe>, or <div class="interactive-embed"> containers. Ensure each embed includes descriptive captions for accessibility.
How to cite
Use the quick export buttons to save citations for reference managers or copy the formatted text directly.
Diogo Ribeiro (2023). Mathematics for Machine Learning: What Each Tool Is For. Faculty of Media Arts and Design, Technical University of Porto. https://diogoribeiro7.github.io/data-science/math_fundamentals/.


