Edexcel International Advanced Level Computer Science, point 6.2.2
Definition
Machine learning (ML) is a part of AI in which a computer learns patterns from data instead of being given explicit rules, and then uses what it has learned to make predictions or decisions on new data.
Traditional programming vs machine learning:
Function and why needed
Some problems are too complex to write rules for: how do you describe in code what a cat looks like, or which emails are spam? ML learns the rules from examples, and improves with more data.
Operation: the process
- Collect data (6.1.2).
- Prepare it: clean it and choose the features (inputs) to use.
- Split it into training data (to learn from) and test data (to check it, not seen during training).
- Train the model: it adjusts its internal numbers (parameters) to fit the training data.
- Test it on the test data and measure the accuracy.
- Use it on new data, and keep monitoring and retraining.
Overfitting: a model that memorises the training data (including its noise) but performs badly on new data. Underfitting: a model that is too simple to capture the pattern. Testing on unseen data shows both.
a. Supervised learning
- Definition: the model learns from labelled data: each training example comes with the correct answer (the label).
- Operation: the model makes a prediction, compares it with the label, and adjusts to reduce the error. It repeats many times. After training it can label new, unlabelled examples.
- Two main tasks:
- Classification: predicting a category (spam or not spam; cat or dog; fraud or genuine).
- Regression: predicting a number (house price; tomorrow's temperature).
- Examples: email spam filters, image recognition, medical diagnosis from scans, predicting house prices, speech recognition.
| Size (m²) | Bedrooms | Price (£) (label) |
|---|---|---|
| 60 | 2 | 180 000 |
| 85 | 3 | 245 000 |
| 120 | 4 | 340 000 |
After learning from many rows like these, the model can predict the price of a new house.
- Benefits: accurate when there is plenty of good labelled data, and easy to measure (compare with the known answers).
- Drawbacks: needs lots of labelled data, which is expensive and slow to produce (people must label it), and it inherits bias in the labels.
b. Unsupervised learning
- Definition: the model learns from unlabelled data: it finds structure and patterns by itself, with no correct answers given.
- Operation: the algorithm looks for similarities and differences in the data.
- Main tasks:
- Clustering: grouping similar items together (for example customer segments).
- Anomaly detection: finding unusual items (fraud, faults).
- Association: finding items that occur together (shoppers who buy X also buy Y).
- Dimensionality reduction: simplifying data while keeping the main patterns.
- Examples: grouping customers by buying behaviour, recommendation systems, detecting unusual network activity, organising photos by similarity.
- Benefits: no labelled data needed, and it can discover patterns people hadn't thought of.
- Drawbacks: the results are harder to check (there is no right answer to compare with), and groups may not be meaningful. They need human interpretation.
Supervised and unsupervised compared
| Supervised | Unsupervised | |
|---|---|---|
| Data | Labelled (inputs with answers) | Unlabelled |
| Goal | Predict a label or value | Find structure |
| Tasks | Classification, regression | Clustering, anomaly detection |
| Checking | Compare with known answers | Harder (no answers) |
| Example | Spam filter | Customer segmentation |
Issues with ML
- Bias: unrepresentative or prejudiced training data gives unfair results.
- Quality of data: poor data gives a poor model ("garbage in, garbage out").
- Lack of explanation: some models are "black boxes".
- Privacy: training uses large amounts of personal data.
- Energy and cost of training large models.
Worked example
Task: a music-streaming service wants to (a) predict whether a subscriber is about to cancel, and (b) group its listeners by taste. Choose supervised or unsupervised learning for each, and justify.
(a) Supervised. The service has past subscribers with a known outcome (cancelled or stayed), so it can train on labelled examples, using features such as hours listened and skips per week. This is a classification task. The model then predicts which current subscribers are likely to cancel, so the service can offer them a deal.
(b) Unsupervised. There are no existing labels for listening tastes, so the service uses clustering to find groups of listeners with similar habits (genres, times of day), then people decide what to call them and which playlists to suggest.
Issue to watch: listening history is personal data, so the service must protect it and tell users how it is used.
Exam tip: the key difference is labelled against unlabelled data. Give an example of each and the type of task (classification or clustering). Mention training and test data, and bias as an issue. Don't say that unsupervised means no human involvement: people still choose, interpret and check.
Check yourself
What is supervised learning?
Learning from labelled data, where each example comes with the correct answer, so the model can predict labels for new data.
What is unsupervised learning?
Learning from unlabelled data, where the model finds patterns or groups by itself.
Give an example task for supervised learning and one for unsupervised learning
Supervised: spam filtering or predicting house prices. Unsupervised: grouping customers into segments or detecting anomalies.
What is the difference between classification and regression?
Both are supervised learning. Classification predicts a category (such as spam or not spam); regression predicts a number (such as a house price).
What is overfitting, and how is it spotted?
The model memorises the training data, including its noise, so it does well on that data but badly on new data. It shows up when the model is tested on data it hasn't seen.