Types of Machine Learning

Updated · 7 min read
easyPython 3.13aimachine-learningsupervised-learningunsupervised-learningreinforcement-learningbeginnersinterview

How does a machine learn when nobody gives it the answers? Navika's teacher can help her learn in three ways. She can give her worked examples with the answers. She can hand her a pile of leaves and ask her to sort them into groups, without naming any. Or she can let her play a game and say "good move" or "bad move" after each turn.

Machines learn in the same three ways, and what the examples look like decides which way fits. This lesson explains supervised, unsupervised and reinforcement learning, with one picture each.

The Three Types at a Glance

Supervised, unsupervised and reinforcement learning

Supervised Learning: Learning with Answers

In supervised learning, every example comes with its correct answer, called a label. The model learns to connect the example to the answer, then predicts answers for new examples.

It is like studying with worked examples: you see the question and the answer many times, until you can answer new questions yourself.

TaskExampleLabel (the answer)
Spam filterAn emailSpam or not spam
Photo sortingA photoDog or cat
House pricingA house's size, bedrooms, age and locationIts sale price
Medical scansAn X-raySigns of disease or not

Supervised tasks come in two kinds. Classification predicts a category, such as spam or not spam. Regression predicts a number, such as a price. Supervised learning is the most common type in everyday products, and the house-price example in "Traditional Programming vs Machine Learning" was a tiny case of it.

Unsupervised Learning: Finding Groups Without Labels

In unsupervised learning, the examples have no labels. The model looks for structure on its own, most often groups of similar examples, called clusters.

It is like sorting a pile of leaves by shape and color without knowing any tree names. You can make sensible groups, but you can't name them.

TaskWhat it finds
Customer groupsShoppers with similar buying habits, such as weekend shoppers or bargain hunters
Topic discoveryGroups of similar support messages, before anyone has named the topics
Unusual activityA payment or login that doesn't fit any normal group

The model finds the groups, but a person still has to decide what each group means and whether it is useful.

Reinforcement Learning: Learning by Trial and Reward

In reinforcement learning, a system called an agent takes actions, and after each action it gets a reward (or none, or a penalty). Over many tries, it learns which actions lead to the most reward.

As an analogy, think of a dog learning tricks: it tries something, gets a treat or not, and repeats what earned the treat. Nobody shows the agent the right answer; the reward tells it how well it did.

ExampleActionReward
AlphaGoChoosing a move in GoWinning the game
A warehouse robotChoosing a pathDelivering quickly without collisions
A game-playing programPressing buttonsPoints scored

Reinforcement learning is powerful, but it needs a very large number of tries, so it is often trained in simulations and games. It is also one of the steps used to make chat assistants more helpful, as a later chapter explains.

Common Mistakes

Thinking unsupervised learning knows what its groups are. It finds similar examples; a person decides what each group means.

Thinking one product uses only one type. Many systems combine types, for example finding customer groups first, then predicting each group's spending.

Confusing a reward with a label. A label is the right answer for one example; a reward only says how good an action turned out.

Thinking reinforcement learning is how most apps learn. Most everyday features, such as spam filters and recommendations, rely mainly on supervised learning.

Interview Corner

What is the difference between supervised and unsupervised learning?

Supervised learning trains on labeled examples, so it learns to predict the answer, such as spam or not spam. Unsupervised learning trains on unlabeled examples and finds structure on its own, such as groups of similar customers.

What is reinforcement learning? Give an example.

An agent learns by trying actions and receiving rewards, and gradually prefers the actions that earn the most reward. AlphaGo improved at Go by playing many games, with winning as the reward.

What are classification and regression?

Both are kinds of supervised learning. Classification predicts a category, such as dog or cat. Regression predicts a number, such as a house price.

Practice

Exercise: name the type. For each task, write supervised, unsupervised or reinforcement, and one sentence explaining why:

  1. Grouping a school's students by study habits, without any categories decided in advance.
  2. Predicting whether a fee payment will be late, from past payments marked late or on time.
  3. Teaching a robot vacuum to clean a room faster, with a reward for each clean square.

Check your answers against the tip above.

Check your understanding:

  1. What is a label?
  2. Why can't an unsupervised model name its groups?
  3. What tells a reinforcement learning agent how well it did?

Quick check: types of machine learning

4 questions
1A spam filter learns from emails marked "spam" or "not spam". Which type is it?
2Which task is unsupervised learning?
3What does a reinforcement learning agent learn from?
4A model predicts the price of a used scooter. Which kind of supervised task is this?

Key Takeaways

Quick reference

TermMeaning
Supervised learningLearning from examples with labels
LabelThe correct answer attached to an example
ClassificationPredicting a category
RegressionPredicting a number
Unsupervised learningFinding structure in examples without labels
ClusterA group of similar examples
Reinforcement learningLearning from rewards for actions
AgentThe system that takes actions in reinforcement learning

Was this tutorial helpful?

Lesson 7 of 186