Every single example a machine-learning model ever sees — a house, an email, a photo, a song —
gets boiled down to the same thing: an ordered list of numbers. No matter how messy or
real-world the original object is, by the time it reaches the model it has become a
Bundle an example's
This is the quiet bridge between machine learning and
Suppose the model needs to predict a house's price. We pick three features — floor area in square metres, number of bedrooms, and age in years — and read them off one real house:
Line those three numbers up, in that order, in a column, and the house is the vector
Text is messier than a house's measurements, but the same trick works. Pick a short list of "key" words to watch for — say free, money, meeting, lunch — and count how many times each one appears in an email. This is called a bag of words: word order and grammar are thrown away, and all that survives is how often each chosen word shows up.
An email that reads "FREE FREE money now, don't miss this free offer!" would count as free: 3, money: 1, meeting: 0, lunch: 0 — giving the feature vector
A calmer email — "Let's grab lunch before the meeting" — counts as free: 0, money: 0, meeting: 1, lunch: 1, giving
Two wildly different emails, each reduced to four numbers a spam filter can compare, measure the distance between, or feed straight into a dot product.
The single most dangerous bug in this whole idea is a silent one: swapping which slot
means what. Say a house model is trained expecting
This is why feature order is treated as a strict contract: feature #2 must mean exactly the same thing for every example in the dataset, and for every new example fed to the model afterwards — training time and prediction time alike. Real ML pipelines pin this down with a fixed schema (a documented, ordered list of feature names) precisely so that "slot 2" can never quietly drift in meaning.
A feature vector is a list of numbers — but plenty of real features are categories, not numbers: a house's neighbourhood, a car's colour, a customer's country. You can't just write "blue" into a numeric vector. Categorical features have to be converted into numbers first.
The simplest fix — numbering the categories
With two features we can actually see it: each example is a dot in the plane, and equally an arrow from the origin. Slide the two features and watch the point move through feature space. Real datasets have hundreds of features — hundreds of dimensions — but the idea is identical; we simply lose the ability to draw it.
Add a third feature and the example becomes a point in three-dimensional feature space. Drag the box to rotate it, and slide the three features to move the point. A dashed line drops the point onto the feature-1 / feature-2 floor: the shaded rectangle there reads off those two coordinates, and the drop's height gives the third. Past three features we can no longer draw it, yet nothing in the maths changes: distances and dot products work the same in 3D, 100D, or 10,000D.
Calling it a vector — not merely a list — is the point. It lets a model measure things:
the
A recommendation engine deciding what to show you next, a spam filter reading your inbox, and an image classifier spotting a cat in a photo have almost nothing in common on the surface — one reads clicks, one reads words, one reads pixels. Yet under the hood, every one of them does exactly the same first step: turn the input into a feature vector. Songs become vectors of listening statistics, emails become vectors of word counts, images become vectors of pixel brightnesses. The feature vector is the universal translation layer between the messy real world and the tidy world of linear algebra — every model, however different its job, starts by speaking this one common language.
The one genuinely hard part nobody automates for you is which features to bother
collecting in the first place — as the "good vs. useless feature" question over in