Supervised and unsupervised learning: what’s the difference?
Machine learning enables computers to identify patterns in data and use them to make predictions or uncover useful insights. Two of its most common approaches are supervised learning and unsupervised learning. The main difference is whether the data comes with known answers, or labels, for the system to learn from.
What is supervised learning?
In supervised learning, a model is trained using examples that include both input data and the correct answer. The model compares its predictions with those answers and adjusts to reduce errors. Once trained, it can make predictions about new data.
For example, a model could learn to identify spam emails from a collection of messages already labelled “spam” or “not spam”. It can then assess incoming emails and estimate which category each belongs to.
Supervised learning is commonly used for two types of task:
- Classification: assigning data to a category, such as identifying whether a transaction is fraudulent or legitimate.
- Regression: predicting a numerical value, such as estimating a property’s sale price or next month’s energy use.
Advantages and challenges
Supervised learning can produce useful, measurable predictions when there is plenty of relevant, accurately labelled data. Its performance can be tested by comparing predictions with known answers.
However, labelled data can be expensive and time-consuming to create. If the examples are incomplete, inaccurate or unrepresentative, the model may learn patterns that do not hold in the real world. It may also repeat biases present in the training data.
What is unsupervised learning?
Unsupervised learning uses data without pre-assigned answers. Rather than being told what to predict, the model looks for structure or patterns in the data. This can help people explore information when they do not yet know what categories or relationships to expect.
For instance, a retailer might use an unsupervised model to group customers according to similarities in their purchasing habits. The groups are not supplied in advance; they emerge from the patterns the model finds.
Common unsupervised learning tasks include:
- Clustering: grouping similar items, customers or documents.
- Dimensionality reduction: simplifying data with many features while retaining as much useful information as possible.
- Anomaly detection: identifying data points that differ markedly from the usual pattern, which may warrant investigation.
Advantages and challenges
Because unsupervised learning does not require labelled examples, it can be useful when labels are unavailable or when a dataset is too large to inspect manually. It can reveal patterns that were not obvious at the outset.
Its results can be harder to interpret and evaluate. A set of clusters, for example, may be mathematically distinct without being meaningful or useful for a particular purpose. Human judgement and knowledge of the subject are often needed to make sense of the findings.
At a glance
| Feature | Supervised learning | Unsupervised learning |
|---|---|---|
| Training data | Includes examples with known answers or labels | Has no supplied answers or labels |
| Main aim | Predict an answer for new data | Find patterns or structure in data |
| Typical tasks | Classification and regression | Clustering, dimensionality reduction and anomaly detection |
| Example | Predict whether a loan application will be repaid | Group customers by similar behaviour |
How do you choose between them?
The right approach depends on the question and the data available. If you have examples with reliable answers and want to predict an outcome, supervised learning may be appropriate. If you want to explore a dataset and discover groups or unusual patterns without predefined answers, unsupervised learning may be a better starting point.
In practice, machine-learning projects can combine approaches. A team might use unsupervised learning to explore customer data, then use the insights to define categories for a supervised model. The choice should also take account of data quality, privacy, the consequences of errors and how the results will be used.
In summary
Supervised learning learns from labelled examples to make predictions. Unsupervised learning works with unlabelled data to find patterns and structure. Neither approach is universally better: each is useful for different questions, and both depend on thoughtful preparation, careful evaluation and appropriate use of data.