# Part 1: What is Supervised Learning?

> "Teaching machines by example — so they can make smart predictions on their own."

**Supervised Learning**, is one of the most critical foundations of machine learning. Here we will learn what it is, how it works, and the two major types of supervised learning — **Regression** and **Classification** — explained in simple terms.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753950294024/9982895c-bccf-4375-96eb-5b27c8d7112d.png align="center")

### Formal Definition

Supervised learning is a type of machine learning where the model is trained on a **labeled dataset**, which means that each input is associated with a corresponding correct output. The goal of supervised learning is to find a function that can accurately map inputs to outputs even when new, unseen inputs are given. The function learns from the patterns it acquires from the training data.

### Layman’s Definition

Let’s think of it as teaching by example. The trainer gives the machine a lot of inputs and their correct outputs. By doing so for long enough, the machine finds out some patterns, so that it can predict the correct/close output values for the new, unseen inputs based on the patterns that it has learned.

## Types of supervised learnings

* **Regression:** a model learns to predict a continuous value, like the price of a house, based on its features. It learns this from the training data and then predict the output values for new input values.
    
    * **Problem:** You want to predict the **price** of a house.
        
    * **Input Features (X):**
        
        * Number of bedrooms
            
        * Size in square feet
            
        * Age of the house
            
        * Location score (e.g., proximity to schools, parks)
            
    * **Output (Y):** House price in dollars.
        
        We will feed the machine learning model with data like the one in the below table.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753426952090/4100aceb-8d5c-4d8f-9797-fde5959d52c6.png align="center")
        
        Then the model learns patterns from this data. When, a **new house** with features like `3 bedrooms`, `1200 sq ft`, `8 years old`, and `8.0 location score`, is given it **predicts** the price — say, **$270,000**.
        
* **Classification:** a model learns to sort data into categories, like labeling emails as "spam" or "not spam". It learns this from the training data with labelled examples.
    
    * **Problem:** We want to classify whether an email is **spam** or **not spam**.
        
    * **Input Features (X):**
        
        * Presence of certain keywords (e.g., "win", "free", "offer")
            
        * Number of links in the email
            
        * Sender email domain
            
        * Use of all caps or exclamation marks
            
    * **Output (Y):** Category label → `"Spam"` or `"Not Spam"`
        
        The training data might look like this.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753427120762/5c0ce70e-fd84-4a20-9830-e5096a0136f4.png align="center")
        
        The model learns from these **labeled examples**. Then, when a **new email** arrives with similar features, the model predicts whether it's spam or not.
        

## Summary

> Supervised learning is a key component of machine learning where models are trained on labeled datasets to predict outcomes based on learned patterns. This method includes two main types: Regression, which predicts continuous values like house prices, and Classification, which sorts data into categories, such as identifying emails as "spam" or "not spam." By providing numerous input-output examples, models become capable of making accurate predictions on new, unseen data.
> 
> Supervised learning powers many real-world applications like facial recognition, speech-to-text systems, fraud detection, recommendation engines etc...

## What’s Next

In the [next part](https://abhis-space.hashnode.dev/part-2-regression-in-machine-learning-predicting-the-future-with-data), we’ll dive deeper into one of the supervised learning algorithms - Regression. We'll explore what regression really means in the context of machine learning, how it works behind the scenes, and why it's so widely used. We'll learn about its different types — such as **Linear Regression**, **Multiple Linear Regression**, and **Polynomial Regression** — and how each is suited to different kinds of problems. Likewise, we'll also look at real-world examples, visualize how the model fits data, and understand key evaluation metrics like **Mean Squared Error (MSE)**.
