UNSUPERVISED
LEARNING
PRESENTED BY,
DVEIN INNOVATIONS
K-MEANS
CLUSTERING
INTRODUCTION
K-Means is an unsupervised clustering algorithm that groups
similar data points into K distinct clusters.
It finds natural groupings in data based on feature similarity
— without any labels.
When to Use K-Means?
Use Case Example Goal
Customer segmentation Group similar customers
Market basket analysis Cluster similar shopping
patterns
Image compression Reduce colors into clusters
WORKING
Step 1: Choose the Number of Clusters (K)
You specify the number of clusters you want (e.g., K = 3)
Choosing K is user-defined or based on methods like the Elbow
Method
Step 2: Initialize K Centroids Randomly
Pick K random points as the initial centroids (center of the clusters)
Step 3: Assign Each Data Point to the Nearest Centroid
Use Euclidean distance to measure closeness
Each data point is assigned to the cluster of the nearest centroid
Step 4: Recalculate the Centroids
For each cluster, calculate the mean of all points in the cluster
This new mean becomes the new centroid
Step 5: Repeat Until Convergence
Repeat Steps 3 and 4 until:
Centroids don’t change (or change very little)
A maximum number of iterations is reached
KEY CONCEPTS
Term Meaning
Cluster A group of similar data points
Centroid The center point of a cluster
Inertia The sum of distances from points
to their centroid
Convergence When centroids no longer move
Elbow Method A technique to choose the best K
CHARACTERISTICS OF K-MEANS
Feature Description
Type Unsupervised
Input Raw data (no labels)
Output Cluster assignment for each point
Assumes Clusters are spherical and equal in
size
Works well when Clear, well-separated clusters exist
PRO’S & CON’S
ADVANTAGES LIMITATIONS
Simple and Easy to Implement Sensitive to initial centroid positions
Fast and Efficient on Large Datasets Requires pre-defined K
Scalable to Big Data Not good for non-spherical clusters
Works Well with Clearly Separable Clusters Affected by outliers
Easy to Interpret and Visualize in 2D/3D Sensitive to feature scaling
HIERARCHICAL CLUSTERING
INTRODUCTION
Hierarchical Clustering is an unsupervised learning
algorithm that builds a hierarchy of clusters either from the
bottom up or top down.
It produces a tree-like structure (dendrogram) showing how data
points are merged or split at different levels.
When to Use Hierarchical Clustering?
Use Case Example Goal
Gene expression analysis Find relationships among genes
Customer grouping Understand nested customer
types
Social network analysis Detect communities or groups
WORKING
Two Main Types:
Agglomerative (Bottom-Up) – Most common
Divisive (Top-Down) – Less common
Step 1: Treat Each Data Point as a Cluster
Start with each point as its own cluster
So, if there are 100 points → we begin with 100 clusters
Step 2: Compute Distance Between All Clusters
Use a distance metric (usually Euclidean)
Also choose a linkage method:
Single Linkage – min distance between any 2 points
Complete Linkage – max distance between any 2 points
Average Linkage – average distance
Ward’s Method – minimizes variance
Step 3: Merge the Closest Clusters
Merge the two closest clusters into one
Now we have one fewer cluster
Step 4: Repeat Until All Points Are in One Cluster
Continue merging until there’s only one big cluster
This creates a hierarchical tree (dendrogram)
Step 5: Choose the Number of Clusters
Use the dendrogram and cut it at a desired height
This height determines the number of clusters
KEY CONCEPTS
Term Meaning
Dendrogram A tree diagram showing the hierarchy
Linkage Method to compute distance between
clusters
Agglomerative Start with points, merge upward
Divisive Start with one big cluster, split
downward
Cutting the dendrogram Selects number of final clusters
PRO’S & CON’S
ADVANTAGES LIMITATIONS
No Need to Specify Number of Not scalable
Clusters (K) No backtracking
Produces a Tree-like Structure Sensitive to noise
(Dendrogram) Choice of linkage matters
Easy to Visualize Relationships
Flexible Distance and Linkage
Options
DBSCAN
INTRODUCTION
DBSCAN is an unsupervised clustering algorithm that groups
data points that are closely packed together (high density areas)
and identifies outliers as noise.
Unlike K-Means, DBSCAN doesn’t require predefining the
number of clusters and can detect clusters of arbitrary shapes.
When to Use DBSCAN?
Use Case Example Goal
Geospatial data analysis Cluster locations
Anomaly detection Identify outliers
Image segmentation Detect dense regions
WORKING
Two Important Parameters
Eps (ε) – The maximum radius to consider around a data point.
MinPts – Minimum number of points required to form a dense
region.
Step 1: Classify Each Point
For each data point, check how many neighbors it has within the
radius ε.
Based on this, points are classified into:
Type of Point Condition
Core Point Has at least MinPts within ε
Border Point Has fewer than MinPts within ε but is in the
neighborhood of a Core Poin
Noise Point Neither Core nor Border
Step 2: Form Clusters
Start with a random point.
If it’s a Core Point, form a new cluster with its neighbors.
Expand the cluster by visiting all neighbors’ neighbors recursively.
Step 3: Mark Noise
Points that don’t fit into any cluster are labeled as noise or outliers.
Step 4: Repeat
Repeat the process until all points are visited and clustered or
marked as noise.
CHARACTERISTICS OF DBSCAN
Feature Description
Doesn’t require K No need to predefine clusters
Handles outliers Marks them explicitly
Can detect complex shapes Unlike K-Means
Distance metric Typically Euclidean
PRO’S & CON’S
ADVANTAGES LIMITATIONS
No Need to Specify Number of Bad choices can lead to poor
Clusters (K) results
Struggles when clusters have
Identifies Outliers Naturally
different densities
Handles Noise Well
Distance becomes less
meaningful
APRIORI ALGORITHM
INTRODUCTION
Apriori is an unsupervised learning algorithm used
for association rule mining to find frequent itemsets in
transactional datasets and to uncover associations between items.
It is widely used in Market Basket Analysis — finding patterns like
"customers who buy X also buy Y."
WHEN TO USE APRIORI?
Use Case Example Goal
Market basket analysis Which products are bought
together
Recommendation systems Suggest complementary
products
Inventory management Stock frequently bought items
together
WORKING
Step 1: Set Thresholds
Support (s): Minimum frequency an itemset must have to be
considered.
Confidence (c): Minimum likelihood of the rule being true.
Lift: How much more likely the consequent is given the antecedent.
Step 2: Generate Frequent Itemsets
Start with individual items → count their support (frequency).
Prune items that don't meet the minimum support threshold.
Example:
{Milk}, {Bread}, {Butter} → check support
Remove those with low support.
Step 3: Build Larger Itemsets
Combine frequent items to form pairs, triplets, etc.
At each step, eliminate combinations that contain infrequent
subsets (Apriori Principle).
Example:
From {Milk}, {Bread} → create {Milk, Bread} if both are frequent.
Step 4: Generate Association Rules
Once frequent itemsets are identified:
For each frequent itemset, generate rules like:
A → B (If A is bought, B is likely to be bought)
Calculate:
Confidence: Probability of B given A.
Lift: Strength of the rule compared to random chance.
Step 5: Filter Rules Based on Confidence & Lift
Only rules that exceed minimum confidence and lift thresholds are
selected as strong rules.
PRO’S & CON’S
ADVANTAGES LIMITATIONS
Easy to Understand and Implement Computationally expensive
Not scalable for large datasets
Provides Clear Association Rules
Needs proper thresholds
Works Well for Market Basket
Analysis Only finds frequent patterns
No Need for Labeled Data
THANK YOU!