FreeLesson 1 of 35 min read
Supervised and unsupervised learning
Learn the core difference between learning from labelled examples and finding structure in unlabelled data.
Before you build any machine learning model, you need to answer one question: do your examples come with the right answers attached? That single fact decides which family of methods you can use, how you measure success, and what the model can honestly claim to have learned.
In this course, a model is a rule, usually a mathematical function with adjustable numbers, that turns an input into an output. Learning means adjusting those numbers using examples. The two big families differ in what the examples contain.
Supervised learning: examples with answers
In supervised learning, every training example is a pair: an input and a label, which is the correct output for that input. The model's job is to learn a mapping from inputs to labels so it can predict labels for new inputs it has never seen.
Supervised tasks come in two main kinds:
- Classification: the label is a category, such as spam or not spam.
- Regression: the label is a number, such as the price of a flat.
- Either way, you can check predictions against known answers.
- The labels act like a teacher marking each attempt, which is where the word supervised comes from.
Example: predicting house prices (made-up data)
Input: floor area 60 m^2, 2 bedrooms -> label: price 180,000
Input: floor area 95 m^2, 3 bedrooms -> label: price 260,000
...hundreds more pairs...
Goal: given a new flat of 75 m^2 with 2 bedrooms, predict its price.
Because each example has a true price, we can measure exactly how wrong each prediction is.
Unsupervised learning: examples without answers
In unsupervised learning, the examples have inputs only. There is no label to predict. Instead, the model looks for structure in the data itself: groups of similar items, unusual items, or a simpler way to describe the data with fewer numbers.
Common unsupervised tasks:
- Clustering: grouping similar examples, such as customers with similar shopping habits.
- Dimensionality reduction: summarising many measurements with a few new ones.
- Anomaly detection: flagging examples that look unlike the rest.
Example: grouping customers (made-up scenario)
Data: for each customer, number of visits per month and average spend.
No labels: nobody has told us which group anyone belongs to.
A clustering method might find three groups: frequent small spenders, rare big spenders, and occasional moderate spenders.
A human then decides whether these groups are useful and what to call them.
Notice the last line. The algorithm does not know that a group means anything. It finds a pattern according to a mathematical definition of similarity that someone chose. Different choices can give different groups, and there is no answer key to say which is correct. That is the price of having no labels.
How to tell which one you need
Ask two questions. First, is there a specific output you want to predict? Second, do you have past examples where that output is already known? If both answers are yes, you have a supervised problem. If you only want to explore or organise data without a target, it is unsupervised.
There are also in-between approaches, such as semi-supervised learning (a few labels, many unlabelled examples) and reinforcement learning (learning from rewards rather than labels). Treat these as extensions; the supervised versus unsupervised split is the foundation.
Next time you meet a machine learning task, name the input, then ask whether a label exists. In the next lesson we stay with supervised learning and ask a harder question: how do we know a model has really learned the pattern, rather than just memorised the examples?
Key takeaways
- Supervised learning uses inputs paired with correct labels and learns to predict labels for new inputs.
- Unsupervised learning uses inputs only and looks for structure such as groups or unusual points.
- To choose, ask whether you have a target output and past examples where it is known.
Check your understanding
Written with AI help. Spotted a mistake? Tell us.