Supervised vs Unsupervised vs Reinforcement Learning: Data, Goals

Machine learning can be divided into three broad types by what it uses as a guide when learning from data. Supervised learning is given pairs of inputs and correct answers (labels) and learns a model that predicts the answer from the input. Unsupervised learning finds groups of similar items, or structures that represent the data with fewer variables, from data alone with no correct answers. Reinforcement learning has an agent (the learner) choose actions in an environment and, through trial and error, learn a way of choosing actions (a policy) that maximizes the total reward it receives as a result. The basic rule: supervised learning when correct answers are available and you want predictions, unsupervised learning when there are no answers and you want to understand the data's structure, and reinforcement learning when you want the learner to judge a sequence of actions by its outcome.

AspectSupervised learningUnsupervised learningReinforcement learning
Training dataPairs of inputs and correct answers (labels)Input data only, with no correct answersRecords of states, actions and rewards from interacting with an environment, collected while acting rather than prepared in advance
How correct answers are givenThe correct output is given for each inputNot givenNo correct answer per action; only an evaluation, the reward, which often arrives with a delay
Learning goalPredict the output correctly for new inputsFind groups and structure in the dataFind a policy that maximizes the total reward received over time
Main tasksRegression (predicting numbers) and classification (predicting classes)Clustering, dimensionality reduction, anomaly detectionChoosing sequences of actions (controlling machines, moves in games, deciding orderings and so on)
Typical methodsLinear regression, logistic regression, decision trees, support vector machines, neural networksk-means clustering, hierarchical clustering, principal component analysis (PCA)Q-learning, policy gradient methods
How to evaluateOn held-out test data, compared with the correct answers using accuracy, precision and recall, mean squared error and so onHard to evaluate without correct answers; judged by measures of how well groups hold together, or by whether people find the results meaningfulBy the total reward obtained (cumulative reward)
Main difficultiesPreparing labels takes time and money; overfitting must be watchedHard to judge whether results are good, and people must interpret what the groups found meanTends to need many trials; trying things on real equipment is risky and costly, so simulation is often used; designing the reward is also hard
Examples of useSpam filtering, image recognition, demand and price forecasting, predicting equipment failuresCustomer segmentation, data visualization and preprocessing for learning, detecting fraudulent transactions and equipment anomaliesGames such as Go, robot control, tuning language model outputs to match human evaluations

Figures are typical orders of magnitude and vary by process generation and product.

When to use which

Supervised learning
When past data records the correct answers (outcomes) and you want to predict the same thing for new data. Most machine learning used in practice falls into this type.
Unsupervised learning
When you want to find groups or trends in data that has no labels, or for which labels are hard to prepare. Dimensionality reduction is also used as preprocessing for supervised learning.
Reinforcement learning
When showing the correct answer step by step is hard but the outcome of actions can be evaluated. It is used for problems where a sequence of actions must be decided while considering results many steps ahead.

FAQ

Is anomaly detection supervised or unsupervised learning?

It can be either, depending on the data. Learning the patterns of normal data and treating anything that departs strongly from them as an anomaly uses no anomaly labels, so it is an unsupervised method. If anomalous examples are also labeled and there are enough of them, the task can be treated as supervised classification. In practice anomalous examples are often very rare, so unsupervised methods are widely used.

What are semi-supervised and self-supervised learning?

Semi-supervised learning combines a small amount of labeled data with a large amount of unlabeled data. Self-supervised learning creates the correct answers from the data itself, for example by hiding part of a text and having the model predict it; it is used, among other things, to pre-train large language models. Both sit between supervised and unsupervised learning and aim to reduce the effort of preparing labels.

What is the main difference between reinforcement learning and supervised learning?

In supervised learning the correct output is given for each input, and the model learns to reduce the difference from it. In reinforcement learning no correct answer is given for each action; the only guide is an evaluation called the reward. Moreover, the reward often comes only after a whole sequence of actions, so the learner must work out for itself which actions were good. It also differs in that the learner collects its own training data through its actions.

Check your understanding

Which of the following supervised learning tasks is a regression task?

  1. ADeciding from the body of an email whether it is spam
  2. BIdentifying which digit from 0 to 9 an image of a handwritten digit shows
  3. CPredicting the price of a house from its floor area, distance to the station and so on
Show answer and explanation

Answer: C. Predicting the price of a house from its floor area, distance to the station and so on

Supervised learning trains a model that predicts an output from an input, using pairs of inputs and correct answers (labels). When the predicted output is a continuous number, the task is called regression; when it is one of a fixed set of classes, it is called classification. A house price is a continuous number, so this is regression. Spam detection is two-class classification, and handwritten digit recognition is ten-class classification.

Which of the following is an example of unsupervised learning?

  1. ADividing customers into several groups with similar buying patterns, using only their purchase histories
  2. BPredicting equipment failures from sensor values, using past records of whether failures occurred as the correct answers
  3. CLearning how to choose moves in a game so that the reward obtained by trial and error becomes large
Show answer and explanation

Answer: A. Dividing customers into several groups with similar buying patterns, using only their purchase histories

Unsupervised learning finds groupings or structure in data that has no correct-answer labels. Typical examples are clustering, which divides similar data into groups, and dimensionality reduction, which represents data with fewer variables. Predicting with the correct answer of whether a failure occurred is supervised learning, and learning actions from rewards is reinforcement learning.

Which of the following describes reinforcement learning?

  1. AGiving a large number of input–answer pairs and learning a function that predicts the answer from the input, so that the difference between prediction and answer becomes small
  2. BAn agent acts in an environment and learns a way of choosing actions (a policy) that makes the total reward it obtains large
  3. CDividing data without correct answers into several groups so that items with similar features end up in the same group
Show answer and explanation

Answer: B. An agent acts in an environment and learns a way of choosing actions (a policy) that makes the total reward it obtains large

In reinforcement learning, the learner (the agent) observes the state of the environment, chooses an action and receives a reward as a result. No correct answer is given for each action; through trial and error the agent learns a policy that maximizes the total reward received over the future. It is used for games such as Go, robot control and tuning the output of language models to match human evaluations.

  1. Which of the following describes the procedure of clustering with k-means (k-means clustering)?
  2. Which of the following describes principal component analysis (PCA)?

Practice Machine Learning Basics questions

Key terms explained

Supervised learning
A machine learning approach that trains a model to predict the correct answer from an input, using data made of pairs of inputs and correct answers (labels). It is called regression when the predicted output is a continuous number and classification when it is one of a fixed set of classes. Models such as linear regression, logistic regression, decision trees, support vector machines and neural networks are used. Preparing the labels often takes considerable effort.
Unsupervised learning
A machine learning approach that finds groupings or structure in data that has no correct-answer labels. It is used for clustering, which divides similar data into groups (k-means and others), dimensionality reduction, which represents data with fewer variables (principal component analysis and others), and anomaly detection, which finds data that differs greatly from the rest. No labels need to be prepared, but the quality of the result is harder to evaluate.
Reinforcement learning
A machine learning approach in which an agent (the learner) observes the state of an environment, chooses actions and learns by trial and error a way of choosing actions (a policy) that maximizes the total reward it receives, including future rewards. No correct answer is given for each action, and rewards often arrive with a delay. It is used for games, robot control and for tuning the output of language models to match human evaluations.
k-means clustering
A representative clustering method that divides data into a predetermined number k of clusters. It places k tentative centers, then repeats assigning each data point to the cluster of the nearest center and moving each center to the mean of its cluster's data until the assignments stop changing. It is simple to compute and works on large data, but the result depends on the initial centers, k must be chosen by the user, and clusters that are not roughly spherical are hard to separate.
Principal component analysis (PCA)
A dimensionality-reduction method that represents data with many variables using fewer variables while losing as little information as possible. It takes the direction of greatest variance in the data as the first principal component, the direction of greatest variance orthogonal to it as the second, and so on, and represents the data with only the leading components. Mathematically this amounts to finding the eigenvectors of the data's covariance matrix. It is used for visualizing data, removing noise and preprocessing before training.
Overfitting
A state in which a model memorizes fine details and chance noise in the training data, so that its error on the training data is small but its error on new data (generalization error) is large. It tends to occur when a complex model with many parameters is trained on little data. It is reduced by adding data, simplifying the model, regularization, dropout, early stopping and similar methods.
Precision and recall
Evaluation metrics for two-class classification models. Precision is the fraction of items predicted positive that are actually positive, TP ÷ (TP + FP), and recall is the fraction of actually positive items that were predicted positive, TP ÷ (TP + FN). In general, changing the decision threshold raises one and lowers the other. Their harmonic mean, 2PR ÷ (P + R), is called the F1 score.

Related comparisons