Intuition The one core idea
Before a computer can learn from data, every piece of that data must become a number — but not all data is number-shaped, and the way we turn it into numbers decides whether the machine hears the truth or a lie. This whole topic is about recognising what kind of thing each column is (a measurement, a name, or a ranked label) so we choose a number-conversion that keeps its real meaning intact.
The parent note throws around μ , σ , R k , e i , summation signs, Euclidean distance, and words like "variance" and "one-hot vector". If you have never met these, the derivations look like spells. This page builds every one of them from nothing, in the order they stack.
Definition A dataset = a table
A dataset is just a grid. Each row is one thing you observed (a house, a customer, an employee). Each column is one property measured for every thing (price, colour, education level). One column is called a feature .
Look at the figure. The whole topic lives inside a single question you ask column by column : what kind of property is this? The red column is the one we are inspecting. There are only three honest answers — number, name, or ranked-name — and the rest of this page defines the tools each answer needs.
Definition Real number and the number line
A real number is any value you can mark as a point on an infinite ruler — the number line . It stretches left (negative) through 0 to the right (positive), with no gaps: between any two marks there is always another.
The picture of a real number is a dot on a horizontal ruler . "Continuous" data (height 175.3 ) can land anywhere on the ruler. "Discrete" data (clicks = 5 ) can only land on the evenly-spaced integer ticks.
∈ ("is an element of")
x ∈ R reads "x is a member of the set of all real numbers", i.e. "x is some point on the number line". The curly R is a name for the whole ruler .
Intuition Why the topic needs this
Every ML algorithm ultimately does arithmetic — adding, multiplying, comparing distances. Arithmetic only makes sense for points on the number line. So the very first job is deciding which columns already live there (numerical) and which must be dropped onto the line by encoding (categorical, ordinal).
The parent writes ∑ i = 1 n x i . Three symbols hide here.
Definition Subscript index
x i
x i means "the i -th value in a list". The little i is a counter : x 1 is the first value, x 2 the second, and so on. n is how many values there are in total .
Definition The summation sign
∑
i = 1 ∑ n x i is a compact instruction: "start the counter i at 1 , add up x i , keep going until i = n ."
∑ i = 1 n x i = x 1 + x 2 + ⋯ + x n
The picture of ∑ is a conveyor belt : items x 1 , x 2 , … roll past and drop into one bucket that keeps a running total.
Intuition Why the topic needs
∑
The mean and the standard deviation both need to "gather up every value and combine them". ∑ is the only honest shorthand for "do this to all n rows" . Without it, formulas would need "+ ⋯ + " everywhere.
Definition Mean (average)
μ
μ = n 1 ∑ i = 1 n x i
In words: add every value, then divide by how many there are. The Greek letter μ ("mew") is the traditional name for this average.
The picture is a seesaw . Drop each data value as a weight on the number line; μ is the exact spot where the plank balances. Values far to the right pull the balance point right; that is why one huge house price drags the mean up.
Intuition Why the topic needs
μ
"Centering" in Z-score scaling means sliding the whole seesaw so the balance point sits over 0 . To slide it there you must first know where the balance point is — that is μ .
Knowing the balance point is not enough — two datasets can share a mean but one is tightly bunched and the other wildly spread. We need a number for spread .
( x i − μ )
The deviation of a value is how far it sits from the balance point , with a sign: negative if left of μ , positive if right.
Why not just average the deviations? Because the left pulls (negative) and right pulls (positive) cancel to exactly zero — that is literally what "balance point" means. So we square each deviation first (a negative squared becomes positive), average those, then take the square root to undo the squaring.
Definition Standard deviation
σ
σ = n 1 ∑ i = 1 n ( x i − μ ) 2
The Greek σ ("sigma") is a typical distance from the mean . Big σ = data sprawls wide; small σ = data clusters tight; σ = 0 = every value identical.
The red band in the figure spans μ − σ to μ + σ — the "usual" zone. The square-then-root trick is why σ is measured in the same units as the data (rupees, cm), unlike raw variance (rupees-squared).
Variance is just σ 2 — the spread before we take the square root. Same information, wrong units for reading off the ruler.
σ can be negative
σ is a distance , and distances are never negative. The square root always returns the non-negative value. If you ever compute a negative σ , you made an arithmetic slip.
Intuition Why the topic needs
σ
After centering, features still have different widths — a price column ranges over hundreds, an age column over tens. Dividing every value by σ squeezes each feature to the same width so no single feature shouts louder than the rest during gradient descent . See Normalization and Scaling .
Categorical encoding lands us in the notation e i ∈ R k . Let's earn it.
Definition Vector — a list of numbers with a direction
A vector is an ordered list of numbers, written [ a , b , c ] . Its picture is an arrow in space: [ 1 , 0 ] points one step east, [ 0 , 1 ] points one step north.
R k
R k is "lists of length k made of real numbers" — the world of k -dimensional arrows. R 2 is a flat page; R 3 is a room. The bold e i is a special arrow: all zeros except a single 1 in slot i . These are the "compass directions" of the space.
The figure shows e 1 = [ 1 , 0 ] and e 2 = [ 0 , 1 ] . The red arrow is a chosen category living purely along its own axis , touching no other. That is exactly the promise of one-hot encoding: give each category its own private direction so the machine never thinks one category is "between" two others.
Intuition Why the topic needs vectors
"Red, Blue, Green" are names with no order. One-hot encoding turns each name into its own e i so that, geometrically, no colour is nearer to another. To even state that fairness, we need the language of arrows in R k . Details in One-Hot Encoding vs Label Encoding .
The parent claims every two one-hot vectors sit 2 apart. Here is the tool behind that.
Definition Euclidean distance
The straight-line gap between two vectors a = [ a 1 , … , a k ] and b = [ b 1 , … , b k ] :
d ( a , b ) = ∑ i = 1 k ( a i − b i ) 2
This is the Pythagoras theorem stretched to k dimensions — square each coordinate gap, add, root.
Worked example Why any two different one-hot vectors are
2 apart
Take UPI = [ 1 , 0 , 0 ] and Cash = [ 0 , 0 , 1 ] . Coordinate gaps: ( 1 − 0 ) , ( 0 − 0 ) , ( 0 − 1 ) = 1 , 0 , − 1 .
d = 1 2 + 0 2 + ( − 1 ) 2 = 2
Every distinct pair gives one + 1 gap and one − 1 gap, always summing to 2 under the root. So all categories are equidistant — none is secretly "closer", which is precisely the neutrality we wanted.
Intuition Why the topic needs distance
Algorithms like KNN and linear models judge similarity by distance. Equal distances between one-hot categories = the model gets no fake hint about which categories are alike. This is the mathematical heart of why one-hot beats label encoding for those models.
Definition The ordering relation
<
a < b means "a comes before / is less than b " on the number line. The picture is strictly leftward on the ruler.
The three data types differ exactly in whether < is meaningful :
Type
Is a < b meaningful?
Is the gap size meaningful?
Numerical
Yes
Yes (75 − 60 really is 15 )
Ordinal
Yes (PhD > Master's)
No (gaps uneven)
Categorical
No (Red vs Blue has no order)
No
Intuition Why this table is the whole topic
Ordinal encoding is allowed to reuse the number line's order (< ) but must not trust its spacing . Categorical encoding must throw away order entirely (hence separate axes). Numerical data alone is allowed both. Every encoding choice in the parent note follows from this one table. For a datetime twist see Feature Engineering from Datetime ; for many-category columns see Handling High-Cardinality Categorical and Curse of Dimensionality .
Real number and number line
Index i and summation sign
Deviation and standard deviation sigma
Vector and space R to the k
Cover the right side and check you can say each aloud.
What does x ∈ R mean in plain words? "x is some point on the infinite number line."
What does ∑ i = 1 n x i instruct you to do? Add up every value from the 1st to the n -th.
What is μ and what picture matches it? The mean — the balance point of the data weights on the number line.
Why square the deviations before averaging in σ ? Raw deviations cancel to zero; squaring removes signs so spread survives.
Can σ ever be negative? No — it is a distance, always ≥ 0 .
What is R k ? The set of all length-k lists of real numbers — k -dimensional arrows.
What is the vector e i ? All zeros except a single 1 in position i — one pure axis direction.
Why are any two one-hot vectors 2 apart? They differ by a
+ 1 and a
− 1 gap, giving
1 + 1 = 2 .
Which data type allows < but not equal spacing? Ordinal.
Which data type forbids < entirely? Categorical.
Return to the parent topic once every checklist line answers itself instantly.