SlideShare a Scribd company logo
K Means
Clustering
Sandhiya
Introduction
 K-Means Clustering is an
iterative algorithm that divides
a dataset into K non-
overlapping clusters where each
data point belongs to the cluster
with the nearest mean. It’s used
in unsupervised learning,
where we don’t have predefined
labels.
How does it Works?
Let’s say you're a shop owner with data about your customers — their age and spending.
You want to group them into similar types of customers.
Step 1: Choose K
Decide how many groups (K) you want. Say K = 2 (maybe high spenders vs. low spenders).
Step 2: Pick K random points as starting centers (called centroids)
These centroids are just random guesses to start with.
Step 3: Assign each customer to the nearest centroid
• If a customer is closer to centroid 1 than to centroid 2 they go into
→ cluster 1.
• Do this for all customers.
Step 4: Move the centroids
• Find the average of all customers in each cluster.
• Move the centroid to that average position (like the new "center").
Step 5: Repeat!
• Reassign customers to their closest (new) centroids.
• Move centroids again.
• Keep repeating until nothing changes much — that's when the algorithm stops.
GOAL:
• Points in the same cluster are as close as possible to each other.
• Clusters are as far apart from each other as possible.
 This is done by minimizing something called WCSS (Within-Cluster Sum of Squares)
 Objective Function
Where:
• K is the number of clusters
• Ci is the set of points in cluster i
• i is the centroid of cluster i
μ
• ∥x i 2 is the Euclidean distance between a point x and the centroid.
−μ ∥
 Distance Metrics
K-Means typically uses Euclidean Distance:
 Image Segmentation
Goal: Divide an image into different regions (like separating background, objects, sky, etc.).
🔍 How K-Means helps:
• Each pixel is treated as a data point (with features like RGB values).
• K-Means clusters pixels with similar color values together.
• The result is an image divided into K segments, each with similar color or texture.
️
🖼️Example:
• A photo of a cat in a garden
• Background (grass)
• The cat's body
• Sky
• Other objects
 Object Detection and Tracking
Goal: Group pixels or features belonging to the same object.
🔍 How K-Means helps:
• Cluster similar features (color, shape, motion) from video frames.
• Helpful as a preprocessing step to extract regions of interest (ROIs) before applying
deep learning.
 Background Subtraction
Goal: Separate moving foreground objects from the static background in videos.
🔍 How K-Means helps:
• Cluster pixels based on movement or color.
• Identify which group stays consistent (background) and which changes (moving
object).
Benefits:
Simple and efficient
Works well with color-based tasks
Fast for smaller images
Easy to combine with other CV techniques
 Limitations:
Doesn’t capture spatial relationships (just color-based)
Not suitable for complex object shapes
Sensitive to noise and outliers

More Related Content

PPTX
Unsupervised learning Modi.pptx
PPTX
Clustering GL Demo V3 - Unsupervised Learning
PDF
Clustering - Machine Learning Techniques
PDF
MLT Unit4.pdfgmgkgmflbmrfmbrfmbfrmbofl;mb;lf
PDF
MLT Unit4.pdffdhngnrfgrgrfflmbpmpphfhbomf
PDF
ch_5_dm clustering in data mining.......
PDF
Unsupervised Learning in Machine Learning
PDF
Computer Vision Computer Vision: Algorithms and Applications Richard Szeliski
Unsupervised learning Modi.pptx
Clustering GL Demo V3 - Unsupervised Learning
Clustering - Machine Learning Techniques
MLT Unit4.pdfgmgkgmflbmrfmbrfmbfrmbofl;mb;lf
MLT Unit4.pdffdhngnrfgrgrfflmbpmpphfhbomf
ch_5_dm clustering in data mining.......
Unsupervised Learning in Machine Learning
Computer Vision Computer Vision: Algorithms and Applications Richard Szeliski

Similar to K Means Clustering_ clustering neighbor. (20)

PPTX
Customer segmentation.pptx
PPT
26-Clustering MTech-2017.ppt
PDF
Cluster Analysis for Dummies
PPT
ClusetrigBasic.ppt
PPT
2002_Spring_CS525_Lggggggfdtfffdfgecture_2.ppt
PPTX
unitvclusteranalysis-221214135407-1956d6ef.pptx
PPTX
Data mining techniques unit v
PPT
DM_clustering.ppt
PPT
Clustering (from Google)
PPTX
Clustering algorithms Type in image segmentation .pptx
PPTX
machine learning - Clustering in R
PPT
CS8091_BDA_Unit_II_Clustering
PPTX
SAMPATH-SEMINAR.pptx ..............................
PPTX
UNIT_V_Cluster Analysis.pptx
PPT
Lec4 Clustering
DOCX
PPTX
sarisus hdyses can create targeted .pptx
PPTX
Unsupervised learning Algorithms and Assumptions
PDF
Chapter#04[Part#01]K-Means Clusterig.pdf
PPTX
Mathematics online: some common algorithms
Customer segmentation.pptx
26-Clustering MTech-2017.ppt
Cluster Analysis for Dummies
ClusetrigBasic.ppt
2002_Spring_CS525_Lggggggfdtfffdfgecture_2.ppt
unitvclusteranalysis-221214135407-1956d6ef.pptx
Data mining techniques unit v
DM_clustering.ppt
Clustering (from Google)
Clustering algorithms Type in image segmentation .pptx
machine learning - Clustering in R
CS8091_BDA_Unit_II_Clustering
SAMPATH-SEMINAR.pptx ..............................
UNIT_V_Cluster Analysis.pptx
Lec4 Clustering
sarisus hdyses can create targeted .pptx
Unsupervised learning Algorithms and Assumptions
Chapter#04[Part#01]K-Means Clusterig.pdf
Mathematics online: some common algorithms
Ad

Recently uploaded (20)

PDF
iTop VPN Crack Latest Version 2025 Free Download With Keygen
PPTX
DPT-MAY24.pptx for review and ucploading
PPTX
A slide for students with the advantagea
PDF
esg-supply-chain-webinar-nov2018hkhkkh.pdf
PPTX
Job-opportunities lecture about it skills
PPTX
Sports and Dance -lesson 3 powerpoint presentation
PPTX
The-Scope-of-Food-Quality-and-Safety.pptx managemement
PPT
APPROACH TO DEVELOPMENTALlllllllllllllllll
PPTX
FINAL PPT.pptx cfyufuyfuyuy8ioyoiuvy ituyc utdfm v
PPTX
CYBER SECURITY PPT.pptx CYBER SECURITY APPLICATION AND USAGE
PDF
Understanding the Rhetorical Situation Presentation in Blue Orange Muted Il_2...
PPT
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
PPTX
microtomy kkk. presenting to cryst in gl
PDF
Entrepreneurship PowerPoint for students
DOC
field study for teachers graduating samplr
PDF
CV of Architect Professor A F M Mohiuddin Akhand.pdf
PDF
313302 DBMS UNIT 1 PPT for diploma Computer Eng Unit 2
PDF
APNCET2025RESULT Result Result 2025 2025
PDF
Blue-Modern-Elegant-Presentation (1).pdf
PDF
Sheri Ann Lowe Compliance Strategist Resume
iTop VPN Crack Latest Version 2025 Free Download With Keygen
DPT-MAY24.pptx for review and ucploading
A slide for students with the advantagea
esg-supply-chain-webinar-nov2018hkhkkh.pdf
Job-opportunities lecture about it skills
Sports and Dance -lesson 3 powerpoint presentation
The-Scope-of-Food-Quality-and-Safety.pptx managemement
APPROACH TO DEVELOPMENTALlllllllllllllllll
FINAL PPT.pptx cfyufuyfuyuy8ioyoiuvy ituyc utdfm v
CYBER SECURITY PPT.pptx CYBER SECURITY APPLICATION AND USAGE
Understanding the Rhetorical Situation Presentation in Blue Orange Muted Il_2...
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
microtomy kkk. presenting to cryst in gl
Entrepreneurship PowerPoint for students
field study for teachers graduating samplr
CV of Architect Professor A F M Mohiuddin Akhand.pdf
313302 DBMS UNIT 1 PPT for diploma Computer Eng Unit 2
APNCET2025RESULT Result Result 2025 2025
Blue-Modern-Elegant-Presentation (1).pdf
Sheri Ann Lowe Compliance Strategist Resume
Ad

K Means Clustering_ clustering neighbor.

  • 2. Introduction  K-Means Clustering is an iterative algorithm that divides a dataset into K non- overlapping clusters where each data point belongs to the cluster with the nearest mean. It’s used in unsupervised learning, where we don’t have predefined labels.
  • 3. How does it Works? Let’s say you're a shop owner with data about your customers — their age and spending. You want to group them into similar types of customers. Step 1: Choose K Decide how many groups (K) you want. Say K = 2 (maybe high spenders vs. low spenders). Step 2: Pick K random points as starting centers (called centroids) These centroids are just random guesses to start with. Step 3: Assign each customer to the nearest centroid • If a customer is closer to centroid 1 than to centroid 2 they go into → cluster 1. • Do this for all customers.
  • 4. Step 4: Move the centroids • Find the average of all customers in each cluster. • Move the centroid to that average position (like the new "center"). Step 5: Repeat! • Reassign customers to their closest (new) centroids. • Move centroids again. • Keep repeating until nothing changes much — that's when the algorithm stops. GOAL: • Points in the same cluster are as close as possible to each other. • Clusters are as far apart from each other as possible.  This is done by minimizing something called WCSS (Within-Cluster Sum of Squares)
  • 5.  Objective Function Where: • K is the number of clusters • Ci is the set of points in cluster i • i is the centroid of cluster i μ • ∥x i 2 is the Euclidean distance between a point x and the centroid. −μ ∥  Distance Metrics K-Means typically uses Euclidean Distance:
  • 6.  Image Segmentation Goal: Divide an image into different regions (like separating background, objects, sky, etc.). 🔍 How K-Means helps: • Each pixel is treated as a data point (with features like RGB values). • K-Means clusters pixels with similar color values together. • The result is an image divided into K segments, each with similar color or texture. ️ 🖼️Example: • A photo of a cat in a garden • Background (grass) • The cat's body • Sky • Other objects
  • 7.  Object Detection and Tracking Goal: Group pixels or features belonging to the same object. 🔍 How K-Means helps: • Cluster similar features (color, shape, motion) from video frames. • Helpful as a preprocessing step to extract regions of interest (ROIs) before applying deep learning.  Background Subtraction Goal: Separate moving foreground objects from the static background in videos. 🔍 How K-Means helps: • Cluster pixels based on movement or color. • Identify which group stays consistent (background) and which changes (moving object).
  • 8. Benefits: Simple and efficient Works well with color-based tasks Fast for smaller images Easy to combine with other CV techniques  Limitations: Doesn’t capture spatial relationships (just color-based) Not suitable for complex object shapes Sensitive to noise and outliers