Introduction to supervised and unsupervised Learning
Machine Learning (ML) is a subfield of Artificial Intelligence (AI) that enables
systems to automatically learn patterns from data and make predictions or
decisions without being explicitly programmed. ML algorithms are broadly
divided into two major types:
1. Supervised Learning
2. Unsupervised Learning
1. Supervised Learning
Definition
Supervised Learning is a type of machine learning where the model is trained
using labeled data. Each input is associated with a correct output, allowing
the model to learn the mapping from inputs (features) to outputs (labels).
Once trained, the model can predict outcomes for new data.
Key Idea
The algorithm learns from examples that include both inputs and
desired outputs.
The goal is to minimize the difference between predicted and actual
results.
Types of Supervised Learning
Type Description Example
Regression Predicts continuous numerical Predicting house prices
values. or temperature.
Classificatio Predicts discrete categorical Email spam detection
n values. or disease
classification.
Examples
Example 1: Cat vs Dog Classification
- Input: Images of cats and dogs.
- Output: Label (“Cat” or “Dog”).
- The model learns to distinguish features of cats and dogs.
Example 2: Salary Prediction
- Input: Experience, education level, age.
- Output: Salary value.
- The model learns the relationship between features and salary.
1
Introduction to supervised and unsupervised Learning
Advantages
High accuracy when enough labeled data is available.
Handles both classification and regression tasks.
Easy to interpret and evaluate.
Limitations
Requires large labeled datasets.
Prone to overfitting on small or biased data.
Expensive and time-consuming labeling process.
2. Unsupervised Learning
Definition
Unsupervised Learning is a type of machine learning that deals with
unlabeled data. The model explores the data and identifies patterns,
structures, or relationships without prior knowledge of the outputs.
Key Idea
The system learns from raw data without explicit supervision.
Useful for exploring data, pattern discovery, and grouping similar data
points.
Examples
Example 1: Customer Segmentation
- Input: Customer purchase data.
- Output: Groups of similar customers.
- Helps identify frequent or high-value customers.
Example 2: Document Clustering
- Input: Articles or news data.
- Output: Grouped by topics (sports, politics, etc.).
- Useful for content organization.
Advantages
Useful when labeled data is unavailable.
Helps uncover hidden structures or relationships.
Reduces data complexity for visualization.
2
Introduction to supervised and unsupervised Learning
Limitations
Hard to evaluate performance (no ground truth).
May produce subjective or meaningless clusters.
Results depend heavily on algorithm parameters.
Comparison Between Supervised and Unsupervised
Learning
Feature Supervised Learning Unsupervised Learning
Data Type Labeled data Unlabeled data
Goal Predict outcomes Discover hidden patterns
Output Known labels Unknown structure
Examples Regression, Classification Clustering, Association
Evaluation Accuracy, Precision Silhouette Score, Visualization
Applicatio Spam detection, disease Market segmentation, anomaly
ns prediction detection
Real-World Applications
Domain Supervised Learning Unsupervised Learning
Healthc Disease diagnosis Grouping similar patients
are
Finance Credit scoring, fraud Identifying unusual transactions
detection
E- Product recommendation Customer segmentation
commer
ce
Agricult Crop disease detection Grouping soil types
ure
Social Sentiment analysis Topic clustering
Media
3. Semi-Supervised Learning
Definition:
3
Introduction to supervised and unsupervised Learning
Semi-Supervised Learning (SSL) is a machine learning technique that
combines a small amount of labeled data with a large amount of
unlabeled data during training.
It lies between:
Supervised Learning → uses only labeled data
Unsupervised Learning → uses only unlabeled data
Semi-supervised learning makes use of both to improve learning accuracy
when labeling data is expensive or time-consuming.
How It Works
1. Start with Labeled Data
A small portion of the dataset is labeled meaning we know the input
and its correct output.
2. Add Unlabeled Data
A large amount of unlabeled data (without target labels) is used to help
the model understand the underlying structure or distribution.
3. Model Training
The model first learns patterns from labeled data, then uses these
patterns to predict labels for the unlabeled data (pseudo-labeling).
4. Re-training
The model is retrained on both the original labeled data and the newly
labeled (pseudo-labeled) data to improve performance.
Example
Suppose you want to train a model to detect plant diseases:
You have 500 labeled leaf images (with disease names).
You also have 10,000 unlabeled leaf images (without labels).
Labeling all 10,000 images would take days — but Semi-Supervised
Learning can use both:
Train model on 500 labeled samples.
Model predicts labels for some unlabeled images.
Add confident predictions to the training set.
Retrain the model for better accuracy.
4
Introduction to supervised and unsupervised Learning
Advantages
Requires less labeled data → saves time and cost.
Improves model accuracy compared to using only labeled data.
Uses unlabeled data effectively, which is usually easy to collect.
Works well when labeling is hard or expensive (like medical or
satellite data).
Disadvantages
If pseudo-labels are incorrect, the model can reinforce errors.
Needs careful balance between labeled and unlabeled data.
Hard to tune for optimal performance.
May fail on noisy or imbalanced data.
Basic terms:
1. Data
Definition:
Data is a collection of facts, observations, or measurements that can be used
for analysis or decision-making.
It can be numbers, text, images, audio, or videos.
Example:
Student marks, temperature readings, or plant leaf images are all data.
2. Dataset
Definition:
A dataset is a collection of data samples used for training or testing a
machine learning model.
Each data sample usually contains input features (X) and sometimes
output labels (Y).
5
Introduction to supervised and unsupervised Learning
Example:
A dataset of plant leaves where each record includes leaf image, color, and
disease label.
Labeled Data
Definition:
Labeled data means each data point has both input and the correct
output (label).
It’s used in supervised learning.
Example:
An image of a potato leaf labeled as “Late Blight”.
Image Label
Late
[Link]
Blight
g
[Link]
g Healthy
Unlabeled Data
Definition:
Unlabeled data means only input features are available, but there is no
output label.
It’s used in unsupervised or semi-supervised learning.
Example:
Leaf images without knowing which disease they have.
Image
Label
[Link]
?
[Link]
?
Overfitting
6
Introduction to supervised and unsupervised Learning
Image
Label
Definition:
Overfitting happens when a model learns too much from
training data, including noise and details,
and performs poorly on new/unseen data.
Simple Words:
The model “memorizes” the training data instead of
“understanding” it.
Example:
If your model gives 99% accuracy on training data but only
60% on test data it’s overfitting.
Underfitting:
Definition:
Underfitting happens when a model is too simple to learn the patterns in
the data.
It performs poorly on both training and test data.
Simple Words:
The model “does not learn enough” from the data.
Example:
Using a straight line (linear regression) for data that follows a curved (non-
linear) pattern.
Fine-Tuning
Definition:
Fine-tuning means improving a pre-trained model by training it further
on a specific dataset.
It adjusts model parameters to make it perform better for a particular task.
Example:
Using a pre-trained model like ResNet,YOLO (trained on ImageNet) and
fine-tuning it for potato leaf disease detection.
7
Introduction to supervised and unsupervised Learning
Dependent Variable
Definition:
The dependent variable is the output or target that we want to predict
or explain.
It depends on other variables (independent variables).
Example:
In predicting house price —
Dependent Variable = Price
Independent Variable
Definition:
The independent variables are the input features that influence or help
predict the output.
Example:
In predicting house price —
Independent Variables = Area, Number of rooms, Location