The Math Behind ML – Week 2 : Intro to Linear Algebra - The Foundations


Hey everyone, welcome to Week 2 of our journey into The Math Behind ML! I hope you’re as excited as I am to dive deeper into how math powers machine learning. If you missed last week, we’re building the foundations for understanding the essential concepts behind machine learning. Today, we’re going to tackle the math that drives it all.
Mathematics forms the fundamental building blocks of machine learning. Whether it's analyzing data, optimizing models, or making predictions, Math is at the heart of it all. Here’s a look at the concepts we’ll explore.
Basic Math For ML :
Linear Algebra – Vectors, Matrices, Eigenvalues, etc.
Analytic Geometry – Geometric interpretations (like Hyper planes, Projections).
Matrix Decomposition – Singular Value Decomposition, Eigen Decomposition, etc.
Vector Calculus – Gradients, Jacobians, Hessians (used in optimization, back prop, etc.)
Probability & Distributions – Bayes’ theorem, joint/marginal/conditional, Gaussian, etc.
Optimization – Gradient descent, convexity, Lagrange multipliers.
Deeper And Advanced Math For ML:
Information Theory – Entropy, KL divergence, and mutual information (used in decision trees, GANs, and VAEs).
Statistics & Statistical Inference – Hypothesis testing, confidence intervals, estimators (important in classical ML and data science).
Numerical Methods – Newton's method, numerical stability, etc. (essential when implementing algorithms from scratch).
Combinatorics – Used in discrete problems, feature engineering, and models like Naive Bayes.
Research-Level Math For ML :
Measure Theory – Shows up in probability theory foundations.
Functional Analysis – Used in kernel methods and advanced theory.
Topology – Rare, but appears in deep theoretical work (e.g., manifolds).
Graph Theory – Crucial in Graph Neural Networks (GNNs)and structured prediction.
Don’t worry, we’ll take it one step at a time – there's no need to feel overwhelmed. We'll explore all these concepts in detail throughout this series, breaking them down so everyone can understand them, no matter where you're starting from.
Number Systems
Let's recall the types of numbers we have at our disposal: Number Systems, Algebraic Expressions. These will help us frame how data is structured and manipulated.
Data is the Key to Machine Learning. At the core of every machine learning model, from simple ones to complex systems that generate images, lies data. But data, in its raw form, isn’t something a computer can directly work with. That’s where numbers come in.
For machines to understand, process, and learn from data—whether it’s images, text, audio, or even video— we must convert it into a numerical format. Numbers are the universal language that machines speak. By transforming different types of data into numbers, we can train models to recognize patterns, make predictions, and even generate new content.
Types Of Numbers
Lets recall the types of numbers available for us to tinker with
Real Numbers : All numbers on the number line, including both rational and irrational.
- Integers : Whole numbers (positive, negative, and zero). No decimals or fractions. [-∞ to +∞]
Rational Numbers : Numbers that can be expressed as a fraction (
1/2
,0.75
,-4
).Irrational Numbers : Numbers that can’t be written as fractions (
π
,√2
,e
). [decimals which do not follow a pattern and Repeats forever] very irrational right…
Let’s dive into some tricky numbers :
Imaginary Numbers [ When Math Gets a Little... Imaginary ] :
A long time ago, when mathematicians tried to square a negative number, they discovered it was impossible within the realm of real numbers. There’s no real number which can satisfy this. So, to work around this, mathematicians invented a new kind of number :
$$i= \sqrt−1 $$
An imaginary number is a number that gives a negative result when squared, which isn’t possible with real numbers.
$$x^2 = -1$$
Imaginary numbers open up a whole other dimension of numbers - literally.
Dimensions [How introducing imaginary unit created another dimension]
Before, we had only one dimension. X-axis which contains all real numbers. Just like the number line. When we introduce the imaginary unit where (i² = -1
), we step off the number line(x-axis) and introduce new axis(Y-axis) and we have a 2d plane.
X- axis : The X-axis represents Real numbers [Real number line].
Y- axis : The Y-axis represents Imaginary numbers [Imaginary number line].
To put it simply, Imagine you're trying to figure out the possible locations of a spaceship that is traveling in two directions at once—one on the real axis (the x-axis), and the other in an entirely new dimension (the y-axis) where 'i' lives.
Imaginary numbers not only allow us to solve equations that had no real solutions, but also play a critical role in fields like wave theory, circuits, quantum physics, and even machine learning.
Complex Numbers :
In machine learning, complex numbers are particularly useful in fields like signal processing and when working with neural networks, where they help in efficient calculations in high-dimensional spaces.
A complex number is a combination of a real number and an imaginary number. It’s written as a+bi, where a is a real number and b is an imaginary number.
$$Complex Numbers = Real Number + Imaginary Number$$
Complex number is like a+b(i)
is a mix of x
and y
planes together.
a
lies in x axis and b
lies in y axis
so, when you put them together, you are saying that start at the origin and move a
steps across X-axis and step up or step down b
steps towards y axis. It’s like plotting a graph in 2D.
Expressions And Algebraic Expressions :
Expressions : Expressions in mathematics are statements that have a minimum of two terms containing numbers or variables, or both, connected by an operator [ +,-,*,/
] in between. These expressions serve as the building blocks of algebra, helping us model relationships between variables and constants.
Algebraic Expressions : Algebraic expressions are the expressions which contains variables, numbers, and mathematical operators.
Types of algebraic expressions :
Monomial : One term ( e.g.,
3x
)Binomials : Two terms ( e.g.,
x + 2
)Trinomial : Three terms ( e.g.,
x² + 3x + 2
)Polynomials : Any number of terms, usually with powers of a variable ( e.g.,
4x³ - 2x² + 7
)
You might ask a question… so, Srikar is Binomial 2d, Trinomial 3d and Polynomial n-dimensions ?
While terms like binomial, trinomial, and polynomial describe the number of terms in an expression, they don’t directly correspond to the number of dimensions. Instead, they suggest the complexity of the shape created when graphed—more terms usually mean more intricate, twisty behavior.
So, How do we distinguish ?
In Math :
You might see
x + 2
(binomial, 1 variable → 1D)Or
x² + 3xy + y² + 2
(polynomial, 2 variables → 2D)Even
a + b + c + d
— 4 terms, 4 variables — but we don’t have to think of it as 4D unless there's a reason.
In Machine Learning :
Each variable = one feature = one dimension
For example, in the equation y = w₁x₁ + w₂x₂ + w₃x₃ + b
, there are 3 features, which correspond to a 3D space—despite having 4 terms.
In ML, dimensions aren’t just abstract — they define how our models “see” and “navigate” the data space.
In machine learning, we use algebraic expressions to represent relationships between variables (or features). Understanding how to manipulate these expressions helps us predict outputs and build effective models.
Now that we've explored some fundamental concepts, let's dive into the role of linear algebra in machine learning.
Linear Algebra: The Secret Arsenal
Now, let’s explore the key tools in linear algebra that empower us to manipulate and analyze data.
Imagine you have an image on a flat 2D screen… but now you want to pop it into 3D space, spin it around, shrink it, or even mix it with other data (like Iron Man—because why not?). Guess what? Linear algebra is the behind-the-scenes wizard that makes all that possible!
And like any good story, we’ve got three heroes that make the magic happen:
Vectors – These are like arrows pointing to where things are or where they’re heading. In machine learning, vectors are how we hold data—whether it's a single image, a line of text, or user behavior. They’re the basic building blocks of everything!
Matrices – Think of these as transformation tools. They rotate, stretch, squish, and flip our data into different shapes. They help us move between 2D and 3D worlds, adjust images, or even shrink huge datasets into simpler ones.
Dot Products – These little math tools tell us how “in sync” two vectors are. Super handy when trying to figure out angles, lighting in graphics, or how similar two things are—like matching faces, finding movie recommendations, or detecting patterns in text.
Linear Algebra is the tool box that helps machines see, think, and learn.
Next week, we’ll dive even deeper into vectors and matrices—unpacking the different types used in machine learning and exploring how we manipulate them. Plus, we’ll tackle some fun problems to help reinforce the concepts!
I’d love to hear your thoughts, suggestions or questions ! Drop them in the comments below, and let’s explore these concepts together.
Subscribe to my newsletter
Read articles from Srikar Amara directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by