Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 53

Types of Machine Learning

Recommended resources

Hello! Welcome to the first lesson in our "Introduction to Machine Learning" module.

In our previous module, we built a solid foundation in probability and statistics, ending with hypothesis testing. You learned how to use data from a sample to make inferences about a population and to determine if observed differences are statistically significant. These skills are not just theoretical; they are the bedrock upon which we build and evaluate machine learning models. How do we know if a model is actually working? How do we measure its performance and compare it to others? The statistical thinking you've developed will be your guide.

Today, we take our first official step into the world of machine learning. Our goal is to understand the "lay of the land" by learning to distinguish between the three main paradigms of machine learning: supervised, unsupervised, and reinforcement learning. Think of this as learning the fundamental categories of tools available to a builder—before you can pick the right hammer, you need to know what a hammer is, what a saw is, and what a drill is.

What is Machine Learning?

At its core, machine learning (ML) is a field of artificial intelligence that empowers computers to learn from data and improve their performance on a task without being explicitly programmed for every scenario. Instead of writing rigid, rule-based code, we provide a model with data and let it discover the underlying patterns itself.

Let's begin by watching a video that uses some excellent analogies to introduce the three main learning approaches. These analogies will serve as our guideposts for the rest of the lesson.

Machine Learning FOR BEGINNERS - Supervised, Unsupervised and Reinforcement Learning

This video from the Python Simplified channel provides simple, intuitive analogies for each of the three major machine learning paradigms. It's a great way to build an initial mental model for each concept.

Watch the following three segments to get a feel for each learning type: Supervised Learning (Parent-child analogy): 00:35 - 02:45 Unsupervised Learning (Child on their own): 04:12 - 05:15 Reinforcement Learning (Learning with rewards): 05:47 - 07:30 Focus on the core idea behind each analogy—what information is the 'learner' given, and how do they learn?

Now that you have those analogies in mind, let's formalize these concepts.


1. Supervised Learning: Learning with a Teacher

As the video explained, supervised learning is like a student learning with an answer key. The "supervision" comes from the fact that we provide the algorithm with a dataset where the correct answers are already known.

The key ingredient is labeled data. Each data point in our training set has two components:

  • Input Features: The characteristics or variables describing the data point (e.g., the pixels of an image, the square footage of a house).
  • Target Label (or Output): The correct answer or the value we want to predict (e.g., the word "cat," the price of the house).

The goal of a supervised learning model is to learn a mapping function that can accurately predict the output label for new, unseen input features.

To understand this better, let's read a concise definition and example.

What is Machine Learning?

The following article from Google Developers provides a clear, concise definition of supervised learning and its sub-types.

Read the section titled "Supervised learning" up to (but not including) "Unsupervised learning". Pay close attention to the distinction between regression and classification.

As you just read, supervised learning problems are typically divided into two categories:

  • Classification: The goal is to predict a discrete category or class.
    • Example: Is this email spam or not spam?
    • Example: Does this image contain a cat, a dog, or a bird?
  • Regression: The goal is to predict a continuous numerical value.
    • Example: What will be the price of this house?
    • Example: What will the temperature be tomorrow?

2. Unsupervised Learning: Finding Patterns on Your Own

Unsupervised learning is what happens when you give the model a dataset without any labels. There is no "teacher" and no answer key. The model's task is to explore the data on its own and find meaningful structure or patterns within it.

Think back to the analogy from the video: a child can group animals into "four-legged" and "two-legged" groups without knowing the names "goat" or "chicken."

The main types of problems solved with unsupervised learning are:

  • Clustering: Grouping similar data points together. This is used extensively in customer segmentation, where a company might want to group its customers based on purchasing behavior to create targeted marketing campaigns.
  • Association: Finding rules that describe relationships between data points. A classic example is "market basket analysis," which might discover that customers who buy diapers also tend to buy beer.
  • Anomaly Detection: Identifying data points that are significantly different from the rest of the dataset. This is crucial for tasks like fraud detection or identifying defective parts in manufacturing.

This next reading from Educative.io will reinforce these concepts.

Supervised vs. unsupervised vs. reinforcement learning

Let's read a short section that defines unsupervised learning and provides some common applications.

Read the section titled "Unsupervised learning". Note the examples of customer segmentation and recommendation systems.


3. Reinforcement Learning: Learning from Experience

Reinforcement learning (RL) is a completely different paradigm. It's not about learning from a static dataset but about learning through interaction with an environment.

The core components of RL are:

  • An Agent: The learner or decision-maker (e.g., a robot, a game-playing program).
  • An Environment: The world the agent operates in (e.g., a room, the board of a chess game).
  • An Action: A move the agent can make.
  • A State: The current situation or configuration of the environment.
  • A Reward or Punishment: Feedback from the environment. A positive reward encourages the agent's recent actions, while a negative reward (punishment) discourages them.

The agent's goal is to learn a policy—a strategy for choosing actions—that maximizes its total cumulative reward over time. It learns this policy through trial and error.

The classic applications are in robotics (teaching a robot to walk), game playing (Google's AlphaGo learned to master the game of Go this way), and autonomous systems like self-driving cars.

Let's read a final definition to solidify this concept.

Supervised vs. unsupervised vs. reinforcement learning

This section provides a concise explanation of reinforcement learning using the example of a robot learning to choose a path.

Read the section titled "Reinforcement learning". Focus on how the agent learns from feedback (rewards).


Summary and Comparison

Let's bring all three concepts together. The following flowchart provides a great visual map of the machine learning landscape.

Machine Learning Types Flowchart
This flowchart visually organizes the machine learning paradigms we've discussed. Supervised learning branches into regression and classification. Unsupervised learning into clustering and association. Reinforcement learning stands on its own, focused on control and decision-making.

Here is a summary table comparing the key characteristics of each approach:

Criterion Supervised Learning Unsupervised Learning Reinforcement Learning
Input Data Labeled (features + correct answers) Unlabeled (features only) No predefined dataset; agent interacts with an environment.
Goal Predict an output based on input features. Discover hidden patterns or structures. Learn a policy to maximize cumulative reward.
Approach Maps inputs to known outputs. Finds similarities and groups data. Trial and error based on rewards/punishments.
Feedback Direct feedback: the model's prediction is compared to the true label. No direct feedback; evaluation is based on pattern quality. Indirect feedback: rewards or punishments from the environment.
Common Problems Classification, Regression Clustering, Association, Anomaly Detection Control, Game playing, Navigation
Test your understanding!

For each of the following scenarios, identify which type of machine learning (Supervised, Unsupervised, or Reinforcement) is most appropriate.

  1. You have a large dataset of customer information and their purchasing history. You want to group customers into distinct segments (e.g., "high-spenders," "budget-shoppers," "new customers") to tailor marketing efforts.
  2. You want to create a model that can predict the future stock price of a company based on its historical prices and other financial metrics.
  3. You are designing a program to control the traffic lights in a city. The goal is to minimize overall traffic congestion and wait times for drivers. The program adjusts the light timings based on real-time traffic flow and receives feedback on how its adjustments affect congestion.
Show answer
  1. Unsupervised Learning (Clustering). The goal is to discover natural groupings in the data without any predefined labels for the customer segments.
  2. Supervised Learning (Regression). You have labeled historical data (past dates and corresponding stock prices), and you are predicting a continuous numerical value (the future price).
  3. Reinforcement Learning. An "agent" (the traffic light controller) is performing "actions" (changing light timings) within an "environment" (the city's traffic grid) to maximize a "reward" (reduced congestion). It learns the best strategy through interaction.

Conclusion

In this lesson, you've taken a high-level tour of the machine learning landscape and learned to differentiate its three primary regions.

Key Takeaways:

  • Supervised Learning uses labeled data to train models that make predictions. It's used for classification (predicting categories) and regression (predicting numbers).
  • Unsupervised Learning works with unlabeled data to discover hidden patterns, such as clusters or associations.
  • Reinforcement Learning involves an agent learning to make optimal decisions through trial and error in an environment, guided by a system of rewards and punishments.

Understanding which paradigm a problem falls into is the first and most crucial step in any machine learning project. It dictates the type of data you need, the algorithms you can use, and how you will evaluate success.

Preview of the Next Lesson:
Now that we have this foundational framework, we will dive deeper into the most common paradigm: supervised learning. In the next lesson, we will explore one of the most fundamental concepts in all of machine learning: the bias-variance tradeoff. This will help us understand why models sometimes make poor predictions and what we can do to diagnose and fix them.