Machine Learning Foundations
Supervised, unsupervised, and a peek at reinforcement
The three ways a model can learn
Three families of machine learning, told apart by one question - do your examples come with an answer, with nothing, or with a reward?
Every machine-learning method you will ever meet belongs to one of three families, and you can sort them with a single question: when the model looks at an example, does it come with the right answer attached, with nothing attached, or with a reward that scores how good its last move was? That one difference - labels, no labels, or a reward signal - decides almost everything about how the thing learns.
One question splits the whole field
The names sound intimidating, but the dividing line is mundane. Supervised learning is studying with an answer key: every example is a pair, an input and the correct output, and the model's whole job is to copy the mapping from one to the other. Unsupervised learning is handed a pile of examples with no answers at all and asked to find the structure hiding inside - which things clump together, which directions matter. Reinforcement learning gets neither; it acts, receives a number saying how well that went, and adjusts to earn more of it.
The picture to hold in your head
| Family | What each example carries | Classic tasks |
|---|---|---|
| Supervised | an input and its correct label | classification, regression |
| Unsupervised | an input only, no label | clustering, dimensionality reduction |
| Reinforcement | actions scored by a reward | game play, robotics, RLHF |
See it: same points, two tasks
The fastest way to feel the split is to hand one pile of points two different jobs. Below are 44 points that naturally form two blobs. Drag the slider from 0% to 100% to control how many of them come with a label. At 0% the machine has no answers, so it does the only thing it can - it invents the two groups by proximity (that is k-means clustering). At 100% every point wears its true colour, so the task flips: the machine now just learns the boundary between the two known classes. Same points; the labels are what change the job.
No labels - the machine invents the two groups by proximity. That is k-means clustering.
Notice what the two extremes are really doing. At 0% the machine never sees the truth, so k-means can misplace points in the overlap - it is guessing the groups, and a couple of guesses may disagree with the real colours. At 100% there is no guessing left: every label is given, and the model only has to draw the line where a point is equally close to the two class means and - the set of points with . In between you are in semi-supervised territory: a few labels sharpen a boundary while the raw structure is still doing some of the work.
The distinction, in one equation each
The cleanest way to see that these are genuinely different problems is to write down what each one is trying to minimise or maximise. Watch where the label appears - and where it vanishes.
Three objectives, one telling difference
Supervised - average the loss between the prediction and the given label , over labeled pairs:
Unsupervised (k-means) - there is no anywhere; you place centers to make points near their closest one:
Reinforcement - the label is replaced by a reward ; a policy maximises expected discounted return:
Same machinery underneath - pick parameters to move a number the right way - but the signal feeding that number is a label, then nothing, then a reward. That is the entire taxonomy.
A peek at reinforcement
The scatter above can't show the third family, because reinforcement learning has no fixed dataset to slide through. Instead there is a loop: the model (the policy) sees a state, picks an action, and the world hands back a new state and a reward. No single step is ever labeled "correct" - the model must figure out, from delayed and noisy scores, which choices paid off. It is how systems learn to play Go, steer robots, and - in Lesson 53 - how RLHF nudges a language model toward answers humans prefer. Notice how the code stops being a call to fit(X, y) and becomes a feedback loop.
# supervised: X has features, y has the answers
model.fit(X, y) # learn the mapping from the labels
# unsupervised: only X, no answer column exists
kmeans.fit(X) # the machine invents the groups
# reinforcement: no dataset at all - a reward loop
for step in range(10000):
action = policy(state) # act on what you see
state, reward = env.step(action) # feedback, not a label
policy.update(reward) # chase more rewardCheck yourself
Photos hand-labeled 'cat' or 'dog' train a model to tag new photos. Which word names that family?
With no labels at all, k-means finds groups purely by proximity. Which word names that task?
The three ML families differ by one question about your examples. What is it, and what does each answer give you?
Try to state it, then check.
Lock it in
- One question sorts every method: does each example carry a label, nothing, or a reward? That decides supervised vs. unsupervised vs. reinforcement.
- Supervised averages a loss between prediction and label; unsupervised (k-means) has no and just places centers to minimise distance; reinforcement replaces the label with a reward it maximises.
- Same points, two jobs: with no labels you cluster by proximity and can misplace overlap points; with full labels you only draw the boundary between known classes. The labels change the task.
- Reinforcement has no fixed dataset - it is a state-action-reward loop, which is why the code stops being
fit(X, y)and becomes a feedback loop.
Primary source
Ask your teacher