Lesson 2 of 4 AI and ML Fundamentals

Choosing a Type of Learning from the Data Available

This lesson explains how the learning approach depends on the data you have, labelled or not, and on what you want the model to do. The exam often describes a scenario and asks which type fits.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish supervised, unsupervised, semi-supervised and reinforcement learning.
  • Distinguish structured, semi-structured and unstructured data.
  • Explain the purpose of the training, validation and test sets.

Types of learning

Machine learning methods differ in the data they learn from. In supervised learning, each training example is labelled with the correct answer, and the model learns to map the inputs, called features, to that answer, called the label or target. It is used for classification, which predicts a category such as fraud or not fraud, and regression, which predicts a number such as a price. In unsupervised learning, the data has no labels, and the model finds structure on its own, such as groups of similar customers, unusual records or a simpler representation of the data.

In reinforcement learning (RL), an agent takes actions in an environment and learns from rewards and penalties to maximise its total reward, which suits robotics, games and resource optimisation. Self-supervised learning creates labels from the data itself, for example by hiding the next word in a sentence and predicting it; this is how large language models are pre-trained. Semi-supervised learning combines a small amount of labelled data with a large amount of unlabelled data, for when labels are scarce. The following table summarises the types.

TypeDataHow it learnsUsed for
SupervisedLabelled: each example has the correct answerMaps inputs (features) to the answer (label or target)Classification (a category) and regression (a number)
UnsupervisedUnlabelledFinds structure on its ownClustering, anomaly detection, dimensionality reduction (e.g. PCA)
Reinforcement (RL)Rewards and penaltiesAn agent takes actions in an environment to maximise rewardRobotics, game playing, resource optimisation
Self-supervisedUnlabelled; labels come from the data itselfE.g. hides the next word and predicts itPre-training LLMs
Semi-supervisedA little labelled plus a lot of unlabelledCombines bothWhen labels are scarce

Labels are often the most expensive part of supervised learning, because people must create them, for example by marking thousands of images as damaged or undamaged. Labelling services such as Amazon SageMaker Ground Truth exist to organise that work. Reinforcement learning also has a role in generative AI: in reinforcement learning from human feedback (RLHF), people rank a model's responses, and those preferences become the reward that teaches the model to give helpful, harmless answers.

The following diagram contrasts the three main types of learning.

Three main types of learning. Supervised learning learns from labelled examples to map features to a label, for classification or regression. Unsupervised learning finds structure in unlabelled data, such as clusters of similar customers or unusual records. Reinforcement learning has an agent take actions in an environment and learn from rewards and penalties. Self-supervised learning, which creates labels from the data itself, is how large language models are pre-trained.
The data decides the type: labels, no labels, or rewards.
Scenario questions

Which type of learning?

Exam skills 1.1.5

Identify the type of learning that each situation calls for.

Log in to try this activity Interactive activities are free with an account.

Types of data

Data is described by how strictly it is organised, and the type usually decides which approach works best. Structured data fits neatly into rows and columns, such as database tables, spreadsheets and time series like daily sales; classic machine learning handles it well. Semi-structured data, such as JSON, has some organisation but no fixed table layout, and either approach can be used. Unstructured data, such as documents, images, audio and video, has no predefined format; it is usually handled by deep learning and foundation models. The following table summarises the types.

TypeExamplesUsually handled by
StructuredDatabase tables, spreadsheets, time series such as daily salesClassic ML
Semi-structuredJSONEither
UnstructuredText documents, images, audio, videoDeep learning and foundation models
Sort into groups

How organised is the data?

Exam skills 1.1.4

Sort each data source by how strictly it is organised.

Log in to try this activity Interactive activities are free with an account.

Training, testing and fit

Available data is split into three sets so that a model can be judged fairly. The training set is the data the model learns from. The validation set is used during development to compare models and tune their settings. The test set is kept aside until the end and used once, to estimate how the model will perform on data it has never seen. If the test set influenced development, its score would be too optimistic. The following table summarises the three sets.

Data setUsed to
Training setLearn the model
Validation setTune hyperparameters and compare models
Test setGive a final, unbiased check on unseen data

Two phases of a model's life use these sets differently. Training is the phase in which the model learns from the training set and produces a model. Inference is the phase in which the finished model is used on new data to make predictions, which happens every time an application calls it.

Comparing results on the training set and the test set shows how well a model fits. A model that overfits has memorised its training examples, including their noise, instead of learning the general pattern: it scores very well on training data but poorly on new data. This is described as high variance, because the model's answers change a great deal with the particular examples it saw. A model that underfits is too simple to capture the pattern, so it scores poorly on both sets; this is described as high bias. The lesson Diagnosing Overfitting and Underfitting and Improving Models explains how each problem is fixed.

True or false

Training and inference

Exam skills 1.1.3 · 1.1.5

Check your understanding of training, inference and the data sets used to judge a model.

Log in to try this activity Interactive activities are free with an account.
Worked example

One company, four learning types

An insurance company has four projects. The deciding question for each is: what data is available, and does it contain the answer?

ProjectDataLearning type
Predict whether a claim is fraudulentPast claims, each marked fraud or not fraudSupervised (classification): labels exist
Group customers into segments for marketingCustomer records with no segment labelsUnsupervised (clustering): no labels; the model finds groups
Teach a robot to sort paper formsNo data set; the robot is rewarded for correct sortingReinforcement learning: learns from rewards
Pre-train a language model on millions of policy documentsRaw text; the next word acts as the labelSelf-supervised: labels come from the data itself

The fraud project also illustrates overfitting. If the model scores 99% on the claims it was trained on but only 70% on next month's claims, it has memorised the training data rather than learned general patterns. The fix is more varied data, a simpler model or regularisation, and always judging the model on a held-back test set.

Check yourself

What kind of data does unsupervised learning use?

Show answer

Unlabelled data. The algorithm finds structure on its own, such as groups of similar customers, without being given the right answers.

Exam Tips

Remember for the exam

  • Labelled data with known answers calls for supervised learning.
  • With no labels, finding groups or outliers calls for unsupervised learning.
  • Learning by trial, error and rewards is reinforcement learning.
  • LLM pre-training, which predicts the next token, is self-supervised learning.
  • An overfitted model performs very well on training data but poorly on new data (high variance).
  • Hold back a test set to measure performance on unseen data.