Skip to content
Lambdian

Supervised vs unsupervised vs reinforcement learning: the difference, with examples

The three kinds of machine learning explained simply: what data each needs, what it learns, typical algorithms and real examples, plus how to tell which one your problem needs.

Lambdian Learn 9 min read

Almost every machine learning method falls into one of three families. The difference is not the algorithm but the kind of feedback the learner gets: correct answers, no answers at all, or a score that arrives after it acts. Once you can name the feedback in your problem, you know which family, and roughly which algorithms, to reach for.

Supervised learning: learning from answered examples

In supervised learning every training example comes with the answer you want the model to produce: a house with its sale price, an email marked spam or not spam, an X-ray with a diagnosis. The model learns a function from inputs x\mathbf{x} to outputs yy and is judged on how well it predicts yy for new inputs.

There are two flavours:

  • Regression predicts a number: price, temperature, demand. Start with linear regression, then try random forests or gradient boosting.
  • Classification predicts a category: spam or not, which digit, which disease. Start with logistic regression, then k-NN, SVMs, trees and neural networks.

The catch is the labels. Someone has to provide them, and that is often the most expensive part of a project. Supervised models are also only as good as their labels: inconsistent or biased labelling becomes inconsistent or biased predictions.

Unsupervised learning: finding structure without answers

Unsupervised learning gets only inputs, no answers. Its job is to describe the data: which points belong together, which directions matter, which examples are strange.

  • Clustering groups similar points: customer segments, topics in documents, regions in an image. k-means, hierarchical clustering, DBSCAN and Gaussian mixtures are the workhorses.
  • Dimensionality reduction compresses many features into a few: PCA for preprocessing and compression, t-SNE for 2-D pictures of high-dimensional data, autoencoders for non-linear compression.
  • Density estimation and anomaly detection learn what "normal" looks like and flag what is not: fraud, faulty sensors, intrusions. Kernel density estimation and isolation forests are good starting points.
  • Association rules find items that occur together, like products bought in the same basket (Apriori).

Because there is no answer key, evaluating unsupervised results is harder. You judge clusters by how compact and separated they are, by whether they help a downstream task, and often by whether a domain expert finds them meaningful.

Reinforcement learning: learning from consequences

In reinforcement learning (RL) nobody tells the learner the right answer. An agent acts in an environment, receives a reward, and must work out which of its actions led to good outcomes, often many steps later. A chess move is only judged good or bad when the game ends.

This makes RL the right family when you need a sequence of decisions rather than a single prediction: game playing, robot control, managing a queue, recommending a sequence of items, tuning a system that reacts to what you do.

The core ideas are the Markov decision process, the value of a state, and the trade-off between exploring new actions and exploiting known good ones. Methods grow from planning with a known model (value iteration) through learning from experience (Q-learning, SARSA) to deep RL (DQN, actor-critic, PPO).

RL is powerful but data-hungry and finicky: it usually needs a simulator in which the agent can fail millions of times cheaply.

Side by side

  • What the data looks like. Supervised: inputs with answers. Unsupervised: inputs only. Reinforcement: experience of states, actions and rewards, generated by the agent itself.
  • What it learns. Supervised: a prediction function. Unsupervised: groups, directions or a density. Reinforcement: a policy, a rule for choosing actions.
  • How you measure success. Supervised: error on held-out examples (accuracy, F1, RMSE). Unsupervised: cluster quality, reconstruction error, usefulness downstream. Reinforcement: total reward collected.
  • Typical first algorithm. Supervised: linear or logistic regression. Unsupervised: k-means or PCA. Reinforcement: Q-learning on a small grid world.

Which one does my problem need?

Ask three questions in order:

  1. Do my actions change what data I see next? If the system makes decisions that affect future situations and you care about long-term outcome, it is reinforcement learning (or, in its simplest one-step form, a multi-armed bandit).
  2. Do I have, or can I get, the correct answer for past examples? If yes, it is supervised. Historical records often contain labels already: whether a loan was repaid, whether a customer churned.
  3. Otherwise, you are exploring structure: unsupervised.

Real projects mix them. A common pattern is unsupervised first (cluster or compress the data), then supervised on top (predict using the clusters or components as features). Semi-supervised and self-supervised learning sit in between: they use a little labelled data plus a lot of unlabelled data, which is how modern language and image models are pre-trained.

Learn these hands-on