Before You Learn Machine Learning, Learn This One Math Topic First

"I thought Python was the most important skill in Machine Learning. Then I discovered that everything—from Linear Regression to LLM—is built on one mathematical language: Linear Algebra."
Have You Ever Wondered What's Happening Behind Machine Learning?
A few days ago, I wrote about why I decided to learn Machine Learning from scratch instead of jumping straight into libraries like Scikit-learn or TensorFlow. At the time, my goal was simple: I didn't just want to build AI applications—I wanted to understand how they actually worked.
As I explored different Machine Learning algorithms, I kept encountering the same mathematical terms everywhere: matrices, vectors, dot products, eigenvalues, and linear transformations. Initially, I ignored them. Like many beginners, I assumed I could learn the mathematics later and focus on building projects first.
However, the deeper I went into Machine Learning, the more I noticed a clear pattern. Every tutorial, research paper, and Deep Learning course eventually pointed back to the same subject: Linear Algebra.
That realization changed the way I viewed Machine Learning. I understood that Machine Learning isn't just programming; it's mathematics expressed through code. Programming languages like Python allow us to implement algorithms, but Linear Algebra provides the mathematical foundation that makes those algorithms work.
In this article, I'll explain what Linear Algebra is, why it plays such an important role in Machine Learning, and why every aspiring Machine Learning engineer should understand its basics—even if you don't consider yourself good at mathematics.
Why Does Machine Learning Need Mathematics?
Imagine you're building a model that can recognize cats in images. At first glance, the process seems straightforward. You collect thousands of cat images, train a model, and eventually it learns to identify cats in new pictures.
But there's an important question hiding behind this process: What does the computer actually see?
When you look at an image, you immediately recognize shapes, colors, ears, eyes, and fur. Your brain effortlessly identifies the object as a cat.
A computer doesn't experience the image that way.
It doesn't know what fur looks like. It doesn't understand ears, whiskers, or tails. In fact, it has no concept of what a "cat" is.
Instead, a computer sees nothing but numbers.
Consider the following 3 × 3 grayscale image:
120 130 140
110 115 125
80 90 100
To us, these values appear to be random numbers. To a computer, however, this is the image. Every number represents the brightness of a single pixel. A small image may contain only a handful of pixel values, but real-world images often contain millions of them.
Now imagine processing millions of numerical values across thousands—or even millions—of images. Organizing, storing, and performing calculations on such enormous collections of numbers would be impossible without an efficient mathematical framework.
This is exactly where Linear Algebra comes in.
So, What Exactly Is Linear Algebra?
When I first heard the term Linear Algebra, I imagined pages filled with intimidating equations and complex mathematical symbols. Fortunately, the reality is much simpler.
At its core, Linear Algebra is the branch of mathematics that deals with organizing, representing, and manipulating collections of numbers. Instead of working with one value at a time, it provides efficient ways to perform calculations on large groups of numbers simultaneously.
This might sound abstract, but it's something we rely on every day. Whether you're listening to a Spotify playlist, receiving movie recommendations on Netflix, navigating with Google Maps, unlocking your phone using face recognition, or chatting with ChatGPT, these systems are continuously processing massive amounts of numerical data.
Although these applications solve very different problems, they all rely on the same mathematical foundation. Linear Algebra provides the tools that make these computations fast, efficient, and scalable.
Without Linear Algebra, modern Artificial Intelligence simply wouldn't exist.
The Secret Behind Every AI Model
Learning about Linear Algebra completely changed how I viewed Machine Learning. Before I started exploring its mathematical foundations, AI models felt almost magical. They seemed like black boxes that accepted data as input and somehow produced intelligent predictions.
As I dug deeper, I realized the reality is much simpler.
Every Machine Learning algorithm performs mathematical operations on numbers. Whether the goal is predicting house prices, recognizing faces, recommending movies, or generating human-like text, the underlying process is fundamentally the same: the model receives numerical data, performs a series of mathematical computations, and produces an output.
The main difference between Machine Learning algorithms lies in how they manipulate those numbers.
For example, Linear Regression relies heavily on matrix operations to find the best-fit relationship between variables. Neural Networks repeatedly multiply matrices while adjusting their weights during training. Image recognition models convert images into matrices of pixel values before extracting meaningful patterns. Recommendation systems compare vectors to measure similarities between users or products. Even Large Language Models (LLMs) like ChatGPT process enormous matrices containing billions of numerical values every second.
Once I understood this common foundation, Machine Learning no longer felt mysterious. Instead of seeing different algorithms as completely unrelated techniques, I began to recognize that they all speak the same mathematical language—Linear Algebra.
Everything Starts With a Single Number
Before we dive into vectors and matrices, it's helpful to begin with the smallest building block in Linear Algebra: the scalar.
A scalar is simply a single numerical value. It doesn't represent a collection of data or a mathematical structure—it is just one number.
Some everyday examples of scalars include:
Your age
Your height
Today's temperature
A product's price
Your monthly salary
In Python, scalar values are nothing more than ordinary variables.
age = 21
temperature = 32.5
salary = 50000
print(age)
print(temperature)
print(salary)
Output
21
32.5
50000
At first glance, scalars may not seem particularly interesting. After all, they are just individual numbers.
However, every complex mathematical structure used in Machine Learning is built from these simple values. Just as a building is constructed from individual bricks, vectors and matrices are formed by combining multiple scalars into larger structures.
You can think of a scalar as a single LEGO brick. On its own, it doesn't accomplish much. But when thousands or even millions of these bricks are combined, they can build remarkably complex systems.
From One Number to Many Numbers
Now imagine you want to describe a student.
Could you do it using only a single number?
Probably not.
Knowing that a student is 20 years old tells us very little. To describe the student more completely, we need additional information such as height and weight.
For example:
Age = 20
Height = 170 cm
Weight = 65 kg
Rather than storing these values separately, we can group them together into a single collection:
[20, 170, 65]
This collection is called a vector.
A vector is simply an ordered list of numbers, where each value represents a particular characteristic, or feature, of an object.
Vectors allow computers to represent real-world objects numerically, making them easy to process and analyze.
Understanding Vectors Through Real-World Examples
The concept of a vector becomes much easier to understand when we relate it to everyday objects.
Imagine you're building a house price prediction model. A house cannot be described by just one number because multiple characteristics influence its value. Instead, we can represent a house using a collection of numerical features:
[3, 2, 1800]
This vector represents:
3 Bedrooms
2 Bathrooms
1800 Square feet
Similarly, we can describe a student using a vector:
[20, 170, 65]
Where:
20 = Age
170 = Height (cm)
65 = Weight (kg)
A car can also be represented as a vector:
[18, 1498, 950000]
Where:
18 = Mileage (km/l)
1498 = Engine Capacity (cc)
950000 = Price
Notice something important. Humans naturally think in terms of concepts like bedrooms, height, weight, mileage, or price. A computer doesn't understand these labels. It only understands the numerical values associated with them.
This is why vectors are so important in Machine Learning. They provide a way to convert real-world objects into numerical representations that algorithms can process efficiently.
Creating a Vector in Python
Fortunately, creating vectors in Python is straightforward with the help of NumPy, one of the most widely used libraries for scientific computing.
import numpy as np
student = np.array([20, 170, 65])
print(student)
Output
[20 170 65]
Although this looks like a simple list of numbers, NumPy treats it as a vector, allowing us to perform mathematical operations efficiently.
We can also access each element using its index.
print(student[0]) # Age
print(student[1]) # Height
print(student[2]) # Weight
Output
20
170
65
This indexing mechanism makes it easy to retrieve or modify individual features whenever needed.
While this example contains only three values, the same concept scales effortlessly to vectors with hundreds or even thousands of features. Whether you're working with customer information, medical records, sensor readings, or image data, Machine Learning models still represent each data sample as a vector.
Why Should You Care About Vectors?
Understanding vectors is more important than simply learning another mathematical term. In Machine Learning, vectors are the standard way of representing data.
Consider a house price prediction problem. Each house has several attributes, such as:
Number of bedrooms
Number of bathrooms
Total area
Age of the house
Instead of storing these values independently, we combine them into a single vector:
[3, 2, 1800, 5]
Here, the vector represents a house with:
3 bedrooms
2 bathrooms
1800 square feet of living space
5 years of age
Every house in the dataset is represented by its own vector. A dataset containing thousands of houses is simply a collection of thousands of these vectors.
This idea extends far beyond housing data. A medical diagnosis model represents each patient as a vector of measurements. A recommendation system represents users and products as vectors. An image classification model converts every image into a high-dimensional vector of pixel values before learning patterns from it.
In other words, vectors are the bridge between real-world information and the mathematical world of Machine Learning.
Because of this, you'll frequently encounter the term feature vector.
Although it may sound technical, the meaning is quite simple: a feature vector is just a list of numbers that describes a single data sample. Once you understand this concept, many Machine Learning tutorials and research papers become much easier to follow.
Why I'm Learning Linear Algebra Before Machine Learning
One reason many beginners skip mathematics is that modern Machine Learning libraries make building models seem incredibly easy. With just a few lines of Python code, you can train a model without understanding the mathematics behind it.
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(X, y)
For many projects, this is enough to produce accurate predictions. However, if you've ever looked at this code and wondered what happens inside the fit() function, you're already asking the right questions.
What exactly is X? Why is it represented as a matrix instead of a simple list? Why do Machine Learning algorithms perform matrix multiplication? How does the model determine the best values for its parameters?
These are questions that libraries intentionally hide from us. Their purpose is to make Machine Learning easier to use, not to explain how it works internally.
As I continued learning, I realized that understanding these concepts requires more than memorizing library functions or following tutorials. It requires understanding the mathematical ideas that power those libraries.
That's why I decided to begin with Linear Algebra.
My goal isn't just to train models or build AI applications. I want to understand what happens behind every prediction, every recommendation, and every generated response. Once you understand the mathematics, Machine Learning stops feeling like a collection of mysterious APIs and starts becoming a logical system that you can reason about, improve, and debug.
What's Next?
So far, we've explored two of the fundamental building blocks of Linear Algebra: scalars and vectors. But a real Machine Learning dataset contains far more than a single vector. It consists of thousands—or sometimes millions—of vectors organized into a structure that algorithms can process efficiently.
In the next article, we'll explore the next essential concept: matrices.
We'll cover:
What a matrix is and how it differs from a vector
The difference between rows and columns
How datasets are stored as matrices
Why matrix operations are at the heart of Machine Learning
Your first matrix operations using NumPy
By the end of the next article, you'll understand how real-world datasets are organized and why matrix operations are central to everything from Linear Regression to modern Deep Learning models.





