# Supervised and unsupervised learning

> Two ways a machine learns: from examples with answers, or by finding patterns on its own.

- Level: Intermediate
- Topics: AI
- URL: https://tidbit.legios.com.ar/supervised-and-unsupervised-learning/
- In Spanish: [Aprendizaje supervisado y no supervisado](https://tidbit.legios.com.ar/es/supervised-and-unsupervised-learning/)

In **supervised learning**, every training example comes with the right answer attached, called a label. Thousands of emails marked "spam" or "not spam", photos of skin marked "benign" or "malignant", past apartments with their sale price. The model studies the pairs and learns a rule that maps input to answer, so it can predict the label for something new. Sorting into categories is called classification; predicting a number, like a price, is regression.

In **unsupervised learning**, there are no answers. The model gets raw data and looks for structure: customers that behave alike (clustering), transactions that look nothing like the rest (anomaly detection, useful against fraud), or a simpler way to describe the data. Nobody tells it what the groups mean; a person has to look at them and decide whether they are useful.

The difference matters because labels are expensive: someone has to write them, often by hand. That is why a third approach became central: **self-supervised learning**, where the data labels itself. Large language models learn this way, by hiding the next word of a real text and trying to guess it, which turns the whole internet into practice material without anyone labeling it.

## An analogy

Supervised is studying with an answer key: you check every exercise. Unsupervised is being handed a box of mixed buttons and sorting them into piles that seem to belong together, with no one telling you the right piles.

## Keep in mind

- Supervised: examples come with labels; the model learns to predict them.
- Unsupervised: no labels; the model finds groups and outliers.
- Labeling data is slow and costly, so it often decides which approach is used.
- LLMs are trained mostly with self-supervised learning on plain text.

## Go deeper

- [Supervised vs. unsupervised learning (IBM)](https://www.ibm.com/think/topics/supervised-vs-unsupervised-learning)
- [Supervised learning on Wikipedia](https://en.wikipedia.org/wiki/Supervised_learning)
- [Unsupervised learning on Wikipedia](https://en.wikipedia.org/wiki/Unsupervised_learning)

## Related terms

- [Training and inference](https://tidbit.legios.com.ar/training-and-inference/): Training builds the model once; inference is using it, millions of times a day.
- [Spam](https://tidbit.legios.com.ar/spam/): Unwanted messages sent in bulk: ads, scams and junk you never asked for.
- [Internet](https://tidbit.legios.com.ar/internet/): A worldwide network of networks that lets any connected device reach any other.
- [Outlier](https://tidbit.legios.com.ar/outlier/): A value that sits far away from the rest of the data.
- [LLM](https://tidbit.legios.com.ar/llm/): A neural network trained on huge amounts of text to predict the next word.
