Unsupervised learning
No labels, just structure
Both lessons so far had ground truth on every single example: the real apartment price, the human-applied spam tag. Every loss function you saw was comparing a guess to a known correct answer. Unsupervised learning removes that answer entirely, the dataset arrives with zero labels attached.
With no correct answer to check against, the algorithm has exactly one tool left: similarity. It measures how close examples are to each other and groups what looks alike, separates what doesn't. That single idea: grouping by similarity, is called clustering, and it's the most common unsupervised task there is.
You're about to do it yourself, the same way you ran the training loop by hand in lesson one, except this time nobody hands you the groups.
Which cluster does this customer belong to?
Two reference customers below. For each new customer, judge which one they resemble more, based only on their numbers, nobody has told you what the 'right' groups are.
When the outlier IS the task
Remember the €40k bonus from last lesson? There, the outlier was a nuisance you had to be aware of when choosing between MAE and MSE. In unsupervised learning, finding exactly that kind of point can BE the entire task. It's called anomaly detection: flag whatever doesn't look like anything else, without ever being told in advance what "normal" or "abnormal" means.
Fraud detection, faulty sensor readings, network intrusions, none of these come with a labeled training set of "here are 10,000 examples of fraud." The system learns what normal looks like from the bulk of the data, then flags what breaks the pattern.
One more unsupervised task worth knowing: dimensionality reduction. A company might track 200 different financial metrics, many of which move together and say almost the same thing. Reducing those 200 columns down to a handful of combined indicators means far less data for a model to process, less compute, less cost. It isn't free: some information is lost in the compression. But when most of what mattered was concentrated in a few underlying patterns anyway, that trade is usually worth it.
Clustering, anomaly detection, or dimensionality reduction?
Same three options every time, which unsupervised task is actually being described?
An online store groups its customers into segments based on purchase behavior, with no predefined categories.
A credit card company automatically flags a transaction that doesn't match a customer's usual spending pattern.
A dataset with 200 financial metrics per company gets compressed into a handful of variables that capture most of the meaningful variation.
A streaming service groups viewers with similar watching habits to power its recommendations.
A factory sensor system notices a machine's vibration readings look nothing like its usual baseline, days before it fails.
An image dataset with millions of pixels per photo gets reduced to a few hundred meaningful components before further processing.
Three tasks, one missing ingredient
Clustering, anomaly detection, and dimensionality reduction all share the same starting condition: no labels, ever. The algorithm works entirely off the structure already sitting inside the data.
That completes two of the three families from lesson one. Supervised learning had a known correct answer for every example. Unsupervised learning has none at all. The last family still needs a proper look: , where there's still no per-example correct answer, but there IS a signal, arriving after the fact, in the form of a reward.
What you learned
- ✓Unsupervised learning works with zero labels, the algorithm's only tool is similarity between examples.
- ✓Clustering groups similar examples together with no predefined categories, the way you just grouped customers by comparing them to two reference points.
- ✓Anomaly detection flags whatever doesn't resemble the rest of the data, without ever being shown a labeled example of what 'abnormal' looks like.
- ✓Dimensionality reduction compresses many correlated variables into far fewer, cutting compute cost at the price of some lost information, never a free trade, but often a worthwhile one.