Numbers, Variables, and Why ML Needs Math
Series: Mastering AI/ML from First Principles
Phase: Math Foundations
Blog #: 02
Topic: Algebra for Machine Learning → Numbers, Variables, and Why ML Needs Math
1. Why this matters
When I started seriously exploring machine learning, I kept hearing the same advice:
“You need to know math.”
That statement always felt incomplete.
It didn’t tell me:
- what math actually matters
- how deep I need to go
- or how it connects to real models
And honestly, most explanations either go too abstract or too superficial. So instead of taking that advice at face value, I decided to do something different.
I started looking at actual machine learning models—not implementations, but the equations behind them.
And what I realized surprised me:
At the core, machine learning is not complicated math. It is simple math used in a structured way.
Before gradients, before optimization, before neural networks—there are just:
- numbers
- variables
- relationships between them
If I don’t understand these deeply, everything else becomes memorization.
This blog is where I slow down and build that foundation properly.
2. Intuition — What is really happening in ML?
Let me strip machine learning down to its simplest form.
Every ML problem looks like this:
“Given some inputs, predict an output.”
Examples:
- Given house features → predict price
- Given user behavior → predict churn
- Given past sales → predict future demand
That means:
- Inputs → numbers
- Output → number
- Model → relationship between those numbers
That’s it (in a simplified way).
Before thinking about models, I need to be comfortable with:
- what numbers represent
- how variables store those numbers
- how relationships are expressed
Because machine learning is really:
turning the real world into numbers and learning relationships between them
3. Core explanation
3.1 Numbers — everything becomes numeric
This was one of the first mindset shifts I had to make.
Computers don’t understand:
- “house”
- “experience”
- “good performance”
- “high demand”
They understand numbers. So everything gets converted.
Real-world concept | Numeric representation |
House size | 1500 (sq ft) |
Experience | 5 (years) |
Temperature | 22 (°C) |
Yes/No | 1 / 0 |
Even things that don’t feel numeric—like text or images—are eventually represented as numbers. That means:
ML is not about objects. It is about numbers representing those objects.
That realization alone made things much clearer for me.
3.2 Variables — giving meaning to numbers
A number by itself is just a value.
A variable gives it meaning.
Instead of saying:
- 1500
- 300000
I say:
- x = 1500 → house size
- y = 300000 → house price
Now I can reason about it.
Variables allow me to:
- label data
- manipulate relationships
- build models
This is where math stops being abstract and starts becoming useful.
3.3 Inputs and outputs — the ML structure
Every ML problem follows the same structure:
- Input variables (features) → what I know
- Output variable (target) → what I want to predict
Example:
- x = house size
- y = house price
Or:
- x = study hours
- y = exam score
This simple structure shows up everywhere.
3.4 Relationships — the heart of everything
Now comes the most important idea.
Instead of memorizing outputs, I define a relationship.
This equation looks simple, but it contains everything:
- x → input
- y → output
- m → how strongly x affects y
- b → baseline
When I first saw this in ML, I thought:
“This is just school math.”
Now I see it differently:
This is a machine learning model.
3.5 What changes in machine learning?
In traditional programming:
- I define rules explicitly
- Example: if x > 10 → do something
In machine learning:
- I give examples
- The system learns the relationship
So instead of choosing m and b, the model learns them from data.
But the structure itself?
Still algebra.
4. Real-world analogy
I started thinking of this like a business problem.
Let’s say I run a small coffee shop.
I want to estimate daily revenue.
Inputs:
- number of customers
- average spend
Output:
total revenue
A simple relationship could be:
Revenue = Customers × AvgSpend
That’s just algebra.
Machine learning takes this idea and makes it:
- data-driven
- flexible
- scalable
But the core idea doesn’t change.
5. Worked examples
Example 1 — Study hours
Let:
y = 5x + 40
x = study hours
y = exam score
If x = 6:
y = 5(6) + 40 = 70
Interpretation:
- Each hour adds 5 points
- Even without studying → baseline is 40
Example 2 — Salary estimation
$$
\text{Salary} = 5000x + 40000
$$
x = years of experience
If x = 10:
This is exactly how early ML models behave.
Example 3 — Multiple inputs (preview)
Later, models become:
$$
y = w_1 x_1 + w_2 x_2 + b
$$
Where:
- size
- location
- rooms
All contribute to price.
This is where ML becomes powerful—but it still starts here.
6. Math (only what I actually need right now)
Linear relationship
y = mx + b
- m → rate of change
- b → baseline
This equation shows up everywhere in ML.
What this leads to later
This one idea evolves into:
- linear regression
- neural networks
- gradient descent
That’s why this matters more than it looks.
7. Python implementation
# Blog 02: Numbers and Variables
import numpy as np
import matplotlib.pyplot as plt
def predict_score(x):
return 5 * x + 40
x = np.array([0, 2, 4, 6, 8, 10])
y = predict_score(x)
print("Study hours:", x)
print("Predicted scores:", y)
plt.figure(figsize=(8,5))
plt.scatter(x, y)
plt.plot(x, y)
plt.xlabel("Study Hours")
plt.ylabel("Score")
plt.title("y = 5x + 40")
plt.grid(True)
plt.show()What this really means
- x → input
- y → output
- function → relationship
This is not ML yet.
But it is the exact mental model ML builds on.
8. Key takeaways
- Everything in ML becomes numbers
- Variables give meaning to those numbers
- Models are relationships between variables
- Algebra is the foundation—not an optional skill
- If I understand this well, ML becomes much easier to reason about
9. What confused me
I initially thought:
“Math comes later, after I learn ML.”
That was completely wrong.
Math is not something I “apply” after ML.
Math is the structure of ML.
The moment I stopped seeing equations as symbols and started seeing them as relationships, things clicked.
10. References
- ISLR — Introduction to Statistical Learning
- ESL — Elements of Statistical Learning
- Hands-On Machine Learning — Aurélien Géron
- NumPy Documentation
- Matplotlib Documentation
Next step
Next blog:
Functions — The Language of Machine Learning
That’s where:
- models = functions
- input → output becomes formal
- graphs start mattering
And things start accelerating.