Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,109 +1,84 @@
---
title: "What is Supervised Machine Learning?"
title: "Demystifying Supervised Machine Learning"
parent: "Module 1: Introduction to Machine Learning"
nav_order: 3
---

# What is Supervised Machine Learning?
# Demystifying Supervised Machine Learning

> These notes are based on the video [ML Zoomcamp 1.3 - Supervised Machine Learning](https://youtu.be/j9kcEuGcC2Y?si=ry3WplRUFQS1R3zt)

<iframe width="560" height="315" src="https://www.youtube.com/embed/j9kcEuGcC2Y?si=YEQcfY4wDsiTRt35" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

Supervised machine learning is a branch of machine learning where we teach algorithms by showing them examples. The term "supervised" comes from the fact that we act as teachers or supervisors, guiding the learning process by providing labeled examples.
Machine learning often sounds like an intimidating field reserved for data scientists and AI researchers. But at its core, it’s about teaching computers to recognize patterns and make predictions. One of the most fundamental approaches in this space is supervised machine learning. Let’s break it down and explore how it works, along with the main problem types it addresses.

## The Core Concept
## What Is Supervised Machine Learning?

In supervised learning:
1. We show the algorithm many examples with known outcomes (labels)
2. The algorithm learns patterns from these examples
3. The algorithm applies these patterns to make predictions on new, unseen examples
Think of supervised learning as teaching by example. Just like a student learns math by practicing problems with solutions provided, a supervised learning model learns by studying data where the outcomes are already known.

## Examples We've Seen
Formally, supervised learning builds a function—let’s call it **g**, that takes in a set of features **(X)** and outputs predictions that approximate a target variable **(y)**.

In previous lessons, we explored:
- **Car price prediction**: We showed the model different cars with their known prices, allowing it to learn patterns that determine car values
- **Spam detection**: We showed the model examples of spam and non-spam messages, enabling it to identify patterns that distinguish between them
- **X:** the input data, representing the characteristics of observations (like the square footage and location of a house).

## The Mathematics of Supervised Learning
- **y:** the outcome we want to predict (like the price of that house).

Supervised learning uses concepts from mathematics and statistics to extract patterns from data.
The magic lies in how the model generalizes from past examples to make accurate predictions on new, unseen data.

## Formal Notation
## Types of Supervised Learning Problems
Supervised learning isn’t a one-size-fits-all solution. Depending on the type of prediction task, it generally falls into one of three categories: regression, classification, or ranking.

We represent our data using:
## 1. Regression
Regression problems deal with predicting continuous numerical values. These could stretch across an infinite range, but often exist within practical limits.

- **Feature Matrix (X)**: A two-dimensional array where:
- Rows represent observations (examples)
- Columns represent features (characteristics)

- **Target Vector (y)**: A one-dimensional array containing the values we want to predict
- **Examples:** Estimating the price of a used car, predicting housing market values, or forecasting stock prices.

For example, in spam detection:
- X would contain features of emails (length, presence of certain words, etc.)
- y would contain labels (1 for spam, 0 for not spam)
- **Output:** Continuous numbers (like 250,000 USD for a house).

## The Goal of Supervised Learning
If the question is “how much?”, regression is likely the tool.

The goal is to find a function g (our model) such that:
## 2. Classification

g(X) ≈ y
Classification tackles problems where the outputs are categories instead of continuous values. It comes in two main flavors:

In other words, when we apply our model g to the feature matrix X, it should produce predictions that are as close as possible to our target values y.
- **Binary Classification:** Predicts between exactly two categories.

## The Training Process
- **Examples:** Email filtering (spam vs. not spam), medical diagnosis (disease vs. no disease).

The process of finding this function g is called "training" and involves:
- **Output:** Often expressed as a probability between 0 and 1, which is then mapped to either category.

1. Feeding the feature matrix X into the model
2. Comparing the model's predictions with the actual target values y
3. Adjusting the model to minimize the difference between predictions and actual values
- **Multi-class Classification:** Predicts among three or more categories.

## Types of Supervised Learning Problems
- **Examples:** Identifying objects in photos as cats, dogs, or cars.

If the question is “which one?”, you’re looking at a classification problem.

Based on the nature of the target variable and the output of our model, we can classify supervised learning into different types:
## 3. Ranking

### 1. Regression Problems
Ranking problems are all about ordering items by relevance. Instead of simply predicting a value or category, the goal is to prioritize results.

- **Output**: A continuous numerical value
- **Example**: Car price prediction (predicting a price in dollars)
- **Range**: Can be any number within a range (often from -∞ to +∞)
- **Other examples**: House price prediction, temperature forecasting, stock price prediction
- **Examples:** Search engines ranking pages, streaming services recommending movies, or e-commerce platforms suggesting products.

### 2. Classification Problems
- **Output:** A relevance score for each item, used to sort them in order.

- **Output**: A category or class label
- **Example**: Image classification (identifying objects in images)
If the question is “what’s most relevant?”, ranking is the answer.

Classification can be further divided into:
## Key Takeaways

#### a. Multi-class Classification Problems
- Classifying into more than two categories
- Example: Identifying if an image contains a car, cat, or dog (3 classes)
Supervised machine learning is one of the most practical and widely used branches of AI. Here are the essentials to remember:

#### b. Binary Classification Problems
- Classifying into exactly two categories
- Example: Spam detection (spam or not spam)
- The model often outputs a probability between 0 and 1
- The target variable is typically encoded as 0 or 1
- It learns from labeled examples: input features (X) matched with known outcomes (y).

### 3. Ranking Problems
- The goal is to build a function that maps features to outcomes with high accuracy.

- **Output**: An ordered list of items
- **Examples**:
- Recommender systems (showing products a user might like)
- Search engines (ordering results by relevance)
- The three main problem types are:

How Ranking Problems Work?
1. The model assigns a score to each item (e.g., probability of user interest)
2. Items are sorted by their scores
3. Top N items are presented to the user
- Regression → Predicts “how much?”

Examples include:
- E-commerce product recommendations
- Search engine results
- Content recommendation systems
- Classification → Predicts “which one?”

## Next Steps
- Ranking → Predicts “what’s most relevant?”

- Among these, **binary classification** remains one of the most common and powerful applications.
---

In the next lesson, we'll explore the bigger picture of organizing machine learning projects and discuss a methodology called CRISP-DM (Cross-Industry Standard Process for Data Mining), which provides a structured approach to planning and executing machine learning projects.
Supervised learning powers many of the technologies we interact with daily, from spam filters to recommendation engines. By understanding its foundations, you can start to appreciate how machines learn to make intelligent predictions—and why it’s such a transformative force in the digital age.