SlideShare a Scribd company logo
K-means Clustering:
Algorithm, Evaluation Methods, and Graph
Hello!
I am Iffat Firozy
I am here because I love to
teach.
2
“
We are given a data set of items, with certain features, and
values for these features (like a vector). The task is to
categorize those items into groups. To achieve this, we will
use the kMeans algorithm; an unsupervised learning
algorithm.
3
The above algorithm in pseudocode:
◎ Specify number of clusters K.
◎ Initialize centroids by first shuffling the dataset and then randomly
selecting K data points for the centroids without replacement.
◎ Keep iterating until there is no change to the centroids. i.e
assignment of data points to clusters isn’t changing.
◎ Compute the sum of the squared distance between data points and
all centroids.
◎ Assign each data point to the closest cluster (centroid).
◎ Compute the centroids for the clusters by taking the average of the
all data points that belong to each cluster.
4
Flowchart of k-means clustering algorithm:
5
LETS’ SOLVE A PROBLEM
6
Problem on K-means clustering.
Given are the points A = (1,2), B = (2,2), C = (2, 1), D = (-1, 4), E = (-2, -
1), F = (-1,-1)
a) Starting from initial clusters Cluster1 = {A} which contains only the
point A and Cluster2 = {D} which contains only the point D, run the K-
means clustering algorithm and report the final clusters.
b) Draw the points on a 2-D grid and check if the clusters make
sense.
7
Initially:
8
X Y
A 1 2
B 2 2
C 2 1
D -1 4
E -2 -1
F -1 -1
CLUSTER X Y CENTROID ASSIGHNMENT
K1 1 2 1,2 1
K2 -1 4 -1,4 2
For row B:
Euclidean Distance: 𝑥 =
(𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2
Here, K1 = (2 − 1)2+(2 − 2)2
=1
K2= (2 + 1)2+(2 − 4)2
=3.60
9
CLUSTER X Y CENTROID ASSIGHNMENT
K1 (1+2)/2 = 1.5 (2+2)/2= 2 1.5,2 1
K2 -1 4 -1,4
X Y
A 1 2
B 2 2
C 2 1
D -1 4
E -2 -1
F -1 -1
For row C:
Distance: 𝑥 =
(𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2
Here, K1 = (2 − 1.5)2+(1 − 2)2
=1.11
K2= (2 + 1)2+(1 − 4)2
=4.24
10
CLUSTER X Y CENTROID ASSIGHNMENT
K1 (1.5+2)/2 = 1.75 (2+1)/2 = 1.5 1.75,1.5 1
K2 -1 4 -1,4
X Y
A 1 2
B 2 2
C 2 1
D -1 4
E -2 -1
F -1 -1
For row E:
Distance: 𝑥 =
(𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2
Here, K1 =
(−2 − 1.75)2+(−1 − 1.5)2
=4.50
K2= (−2 + 1)2+(−1 − 4)2
=5.09
11
CLUSTER X Y CENTROID ASSIGHNMENT
K1 (1.75-2)/2 = -
0.125
(1.5-1)/2 = 0.25 -0.125, 0.25 1
K2 -1 4 -1,4
X Y
A 1 2
B 2 2
C 2 1
D -1 4
E -2 -1
F -1 -4
For row F:
Distance: 𝑥 =
(𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2
Here, K1 =
(−1 + 0.125 )2+(−4 − .25)2
=4.33
K2= (−1 + 1)2+(−4 − 4)2
=5
12
CLUSTER X Y CENTROID ASSIGHNMENT
K1 (0.125-1)/2 = -.43 (.25-1)/2 = -.375 -.43, -1.85 1
K2 -1 4 -1,4
X Y
A 1 2
B 2 2
C 2 1
D -1 4
E -2 -1
F -1 -1
Final Clustering & Assignments:
13
X Y ASSIGNMENT
A 1 2 1
B 1.5 2 1
C 1.75 1.5 1
D -1 4 1
E .125 .25 1
F -..43 -.375 1
2D Graph:
14
2 2
1
4
-1
-4
-6
-4
-2
0
2
4
6
-3 -2 -1 0 1 2 3
Y-Values
2 2
1.5
4
0.25
-0.375
-2
-1
0
1
2
3
4
5
-2 -1 0 1 2 3
Y-Values
AFTER CLUSTERINGBEFORE CLUSTERING
Thanks!
Any questions?
You can find me at:
ifirozy@gmail.com
15

More Related Content

What's hot

Waldie pd2
Waldie pd2Waldie pd2
Waldie pd2
guero456
 
Modeling quadratic fxns
Modeling quadratic fxnsModeling quadratic fxns
Modeling quadratic fxns
North Carolina Virtual Public School
 
January 9, 2015 intro to functions
January 9, 2015 intro to functionsJanuary 9, 2015 intro to functions
January 9, 2015 intro to functions
khyps13
 
Fuzzy c means clustering protocol for wireless sensor networks
Fuzzy c means clustering protocol for wireless sensor networksFuzzy c means clustering protocol for wireless sensor networks
Fuzzy c means clustering protocol for wireless sensor networks
mourya chandra
 
1 illustrating limit of a function
1 illustrating limit of a function1 illustrating limit of a function
1 illustrating limit of a function
JRCatador
 
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in MatlabMathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in Matlab
COMSATS Abbottabad
 
Mathematical Modelling of Electrical/Mechanical modellinng in MATLAB
Mathematical Modelling of Electrical/Mechanical modellinng in MATLABMathematical Modelling of Electrical/Mechanical modellinng in MATLAB
Mathematical Modelling of Electrical/Mechanical modellinng in MATLAB
COMSATS Abbottabad
 
A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...
A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...
A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...
Jialin LIU
 
Analysis of Electro-Mechanical System
Analysis of Electro-Mechanical SystemAnalysis of Electro-Mechanical System
Analysis of Electro-Mechanical System
COMSATS Abbottabad
 
8th pre alg -l41
8th pre alg -l418th pre alg -l41
8th pre alg -l41
jdurst65
 
Logarithm Bases IA
Logarithm Bases IALogarithm Bases IA
Logarithm Bases IA
bank8787
 
Pythagorean theorem and distance formula
Pythagorean theorem and distance formulaPythagorean theorem and distance formula
Pythagorean theorem and distance formula
41178582
 
Pythagorean theorem and distance formula
Pythagorean theorem and distance formulaPythagorean theorem and distance formula
Pythagorean theorem and distance formula
41178582
 
Introduction to MATLAB
Introduction to MATLAB Introduction to MATLAB
Introduction to MATLAB
COMSATS Abbottabad
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLAB
Pranoti Doke
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Mohanlal Sukhadia University (MLSU)
 
Paper computer
Paper computerPaper computer
Paper computer
bikram ...
 
Power Series
Power SeriesPower Series
Imaginary Number
Imaginary NumberImaginary Number

What's hot (19)

Waldie pd2
Waldie pd2Waldie pd2
Waldie pd2
 
Modeling quadratic fxns
Modeling quadratic fxnsModeling quadratic fxns
Modeling quadratic fxns
 
January 9, 2015 intro to functions
January 9, 2015 intro to functionsJanuary 9, 2015 intro to functions
January 9, 2015 intro to functions
 
Fuzzy c means clustering protocol for wireless sensor networks
Fuzzy c means clustering protocol for wireless sensor networksFuzzy c means clustering protocol for wireless sensor networks
Fuzzy c means clustering protocol for wireless sensor networks
 
1 illustrating limit of a function
1 illustrating limit of a function1 illustrating limit of a function
1 illustrating limit of a function
 
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in MatlabMathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in Matlab
 
Mathematical Modelling of Electrical/Mechanical modellinng in MATLAB
Mathematical Modelling of Electrical/Mechanical modellinng in MATLABMathematical Modelling of Electrical/Mechanical modellinng in MATLAB
Mathematical Modelling of Electrical/Mechanical modellinng in MATLAB
 
A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...
A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...
A Mathematically Derived Number of Resamplings for Noisy Optimization (GECCO2...
 
Analysis of Electro-Mechanical System
Analysis of Electro-Mechanical SystemAnalysis of Electro-Mechanical System
Analysis of Electro-Mechanical System
 
8th pre alg -l41
8th pre alg -l418th pre alg -l41
8th pre alg -l41
 
Logarithm Bases IA
Logarithm Bases IALogarithm Bases IA
Logarithm Bases IA
 
Pythagorean theorem and distance formula
Pythagorean theorem and distance formulaPythagorean theorem and distance formula
Pythagorean theorem and distance formula
 
Pythagorean theorem and distance formula
Pythagorean theorem and distance formulaPythagorean theorem and distance formula
Pythagorean theorem and distance formula
 
Introduction to MATLAB
Introduction to MATLAB Introduction to MATLAB
Introduction to MATLAB
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLAB
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 
Paper computer
Paper computerPaper computer
Paper computer
 
Power Series
Power SeriesPower Series
Power Series
 
Imaginary Number
Imaginary NumberImaginary Number
Imaginary Number
 

Similar to K-means Clustering || Data Mining

K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
Clustering
ClusteringClustering
Clustering
Rashmi Bhat
 
coefficient variation
coefficient variationcoefficient variation
coefficient variation
MARIA KATRINA MACAPAZ
 
Enhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial DatasetEnhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial Dataset
AlaaZ
 
Presentacion unidad 4
Presentacion unidad 4Presentacion unidad 4
Presentacion unidad 4
Camilo Leal Leal
 
K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)
Abdullah al Mamun
 
08 clustering
08 clustering08 clustering
Lecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptLecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.ppt
SyedNahin1
 
Geometry unit 12.5
Geometry unit 12.5Geometry unit 12.5
Geometry unit 12.5
Mark Ryder
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structures
Kàŕtheek Jåvvàjí
 
Obj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance FormulasObj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance Formulas
smiller5
 
K means clustering
K means clusteringK means clustering
K means clustering
Ahmedasbasb
 
1.1.1C Midpoint and Distance Formulas
1.1.1C Midpoint and Distance Formulas1.1.1C Midpoint and Distance Formulas
1.1.1C Midpoint and Distance Formulas
smiller5
 
11-2-Clustering.pptx
11-2-Clustering.pptx11-2-Clustering.pptx
11-2-Clustering.pptx
paktari1
 
Lec13 Clustering.pptx
Lec13 Clustering.pptxLec13 Clustering.pptx
Lec13 Clustering.pptx
Khalid Rabayah
 
QUARTILE DEVIATION
QUARTILE DEVIATIONQUARTILE DEVIATION
QUARTILE DEVIATION
MARIA KATRINA MACAPAZ
 
TunUp final presentation
TunUp final presentationTunUp final presentation
TunUp final presentation
Gianmario Spacagna
 
2.1 Rectangular Coordinates
2.1 Rectangular Coordinates2.1 Rectangular Coordinates
2.1 Rectangular Coordinates
smiller5
 
Business analytics course in delhi
Business analytics course in delhiBusiness analytics course in delhi
Business analytics course in delhi
bhuvan8999
 
data science course in delhi
data science course in delhidata science course in delhi
data science course in delhi
devipatnala1
 

Similar to K-means Clustering || Data Mining (20)

K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
 
Clustering
ClusteringClustering
Clustering
 
coefficient variation
coefficient variationcoefficient variation
coefficient variation
 
Enhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial DatasetEnhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial Dataset
 
Presentacion unidad 4
Presentacion unidad 4Presentacion unidad 4
Presentacion unidad 4
 
K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)
 
08 clustering
08 clustering08 clustering
08 clustering
 
Lecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptLecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.ppt
 
Geometry unit 12.5
Geometry unit 12.5Geometry unit 12.5
Geometry unit 12.5
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structures
 
Obj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance FormulasObj. 7 Midpoint and Distance Formulas
Obj. 7 Midpoint and Distance Formulas
 
K means clustering
K means clusteringK means clustering
K means clustering
 
1.1.1C Midpoint and Distance Formulas
1.1.1C Midpoint and Distance Formulas1.1.1C Midpoint and Distance Formulas
1.1.1C Midpoint and Distance Formulas
 
11-2-Clustering.pptx
11-2-Clustering.pptx11-2-Clustering.pptx
11-2-Clustering.pptx
 
Lec13 Clustering.pptx
Lec13 Clustering.pptxLec13 Clustering.pptx
Lec13 Clustering.pptx
 
QUARTILE DEVIATION
QUARTILE DEVIATIONQUARTILE DEVIATION
QUARTILE DEVIATION
 
TunUp final presentation
TunUp final presentationTunUp final presentation
TunUp final presentation
 
2.1 Rectangular Coordinates
2.1 Rectangular Coordinates2.1 Rectangular Coordinates
2.1 Rectangular Coordinates
 
Business analytics course in delhi
Business analytics course in delhiBusiness analytics course in delhi
Business analytics course in delhi
 
data science course in delhi
data science course in delhidata science course in delhi
data science course in delhi
 

More from Iffat Firozy

Association Rule Mining || Data Mining
Association Rule Mining || Data MiningAssociation Rule Mining || Data Mining
Association Rule Mining || Data Mining
Iffat Firozy
 
Data Preprocessing || Data Mining
Data Preprocessing || Data MiningData Preprocessing || Data Mining
Data Preprocessing || Data Mining
Iffat Firozy
 
Decision Tree || Data Mining ..
Decision Tree || Data Mining ..Decision Tree || Data Mining ..
Decision Tree || Data Mining ..
Iffat Firozy
 
Data mining || Decision tree..
Data mining || Decision tree..Data mining || Decision tree..
Data mining || Decision tree..
Iffat Firozy
 
Data Mining || Decision Tree
Data Mining || Decision TreeData Mining || Decision Tree
Data Mining || Decision Tree
Iffat Firozy
 
Hidden Markov Model
Hidden Markov ModelHidden Markov Model
Hidden Markov Model
Iffat Firozy
 
Internet of things (Iot)
Internet of things (Iot)Internet of things (Iot)
Internet of things (Iot)
Iffat Firozy
 
Hospital Introducer & Direction Giving Robot.
Hospital Introducer & Direction Giving Robot.Hospital Introducer & Direction Giving Robot.
Hospital Introducer & Direction Giving Robot.
Iffat Firozy
 
How to calculate SGPA & CGPA
How to calculate SGPA & CGPAHow to calculate SGPA & CGPA
How to calculate SGPA & CGPA
Iffat Firozy
 

More from Iffat Firozy (9)

Association Rule Mining || Data Mining
Association Rule Mining || Data MiningAssociation Rule Mining || Data Mining
Association Rule Mining || Data Mining
 
Data Preprocessing || Data Mining
Data Preprocessing || Data MiningData Preprocessing || Data Mining
Data Preprocessing || Data Mining
 
Decision Tree || Data Mining ..
Decision Tree || Data Mining ..Decision Tree || Data Mining ..
Decision Tree || Data Mining ..
 
Data mining || Decision tree..
Data mining || Decision tree..Data mining || Decision tree..
Data mining || Decision tree..
 
Data Mining || Decision Tree
Data Mining || Decision TreeData Mining || Decision Tree
Data Mining || Decision Tree
 
Hidden Markov Model
Hidden Markov ModelHidden Markov Model
Hidden Markov Model
 
Internet of things (Iot)
Internet of things (Iot)Internet of things (Iot)
Internet of things (Iot)
 
Hospital Introducer & Direction Giving Robot.
Hospital Introducer & Direction Giving Robot.Hospital Introducer & Direction Giving Robot.
Hospital Introducer & Direction Giving Robot.
 
How to calculate SGPA & CGPA
How to calculate SGPA & CGPAHow to calculate SGPA & CGPA
How to calculate SGPA & CGPA
 

Recently uploaded

REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Vivekanand Anglo Vedic Academy
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 

Recently uploaded (20)

REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 

K-means Clustering || Data Mining

  • 2. Hello! I am Iffat Firozy I am here because I love to teach. 2
  • 3. “ We are given a data set of items, with certain features, and values for these features (like a vector). The task is to categorize those items into groups. To achieve this, we will use the kMeans algorithm; an unsupervised learning algorithm. 3
  • 4. The above algorithm in pseudocode: ◎ Specify number of clusters K. ◎ Initialize centroids by first shuffling the dataset and then randomly selecting K data points for the centroids without replacement. ◎ Keep iterating until there is no change to the centroids. i.e assignment of data points to clusters isn’t changing. ◎ Compute the sum of the squared distance between data points and all centroids. ◎ Assign each data point to the closest cluster (centroid). ◎ Compute the centroids for the clusters by taking the average of the all data points that belong to each cluster. 4
  • 5. Flowchart of k-means clustering algorithm: 5
  • 6. LETS’ SOLVE A PROBLEM 6
  • 7. Problem on K-means clustering. Given are the points A = (1,2), B = (2,2), C = (2, 1), D = (-1, 4), E = (-2, - 1), F = (-1,-1) a) Starting from initial clusters Cluster1 = {A} which contains only the point A and Cluster2 = {D} which contains only the point D, run the K- means clustering algorithm and report the final clusters. b) Draw the points on a 2-D grid and check if the clusters make sense. 7
  • 8. Initially: 8 X Y A 1 2 B 2 2 C 2 1 D -1 4 E -2 -1 F -1 -1 CLUSTER X Y CENTROID ASSIGHNMENT K1 1 2 1,2 1 K2 -1 4 -1,4 2
  • 9. For row B: Euclidean Distance: 𝑥 = (𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2 Here, K1 = (2 − 1)2+(2 − 2)2 =1 K2= (2 + 1)2+(2 − 4)2 =3.60 9 CLUSTER X Y CENTROID ASSIGHNMENT K1 (1+2)/2 = 1.5 (2+2)/2= 2 1.5,2 1 K2 -1 4 -1,4 X Y A 1 2 B 2 2 C 2 1 D -1 4 E -2 -1 F -1 -1
  • 10. For row C: Distance: 𝑥 = (𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2 Here, K1 = (2 − 1.5)2+(1 − 2)2 =1.11 K2= (2 + 1)2+(1 − 4)2 =4.24 10 CLUSTER X Y CENTROID ASSIGHNMENT K1 (1.5+2)/2 = 1.75 (2+1)/2 = 1.5 1.75,1.5 1 K2 -1 4 -1,4 X Y A 1 2 B 2 2 C 2 1 D -1 4 E -2 -1 F -1 -1
  • 11. For row E: Distance: 𝑥 = (𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2 Here, K1 = (−2 − 1.75)2+(−1 − 1.5)2 =4.50 K2= (−2 + 1)2+(−1 − 4)2 =5.09 11 CLUSTER X Y CENTROID ASSIGHNMENT K1 (1.75-2)/2 = - 0.125 (1.5-1)/2 = 0.25 -0.125, 0.25 1 K2 -1 4 -1,4 X Y A 1 2 B 2 2 C 2 1 D -1 4 E -2 -1 F -1 -4
  • 12. For row F: Distance: 𝑥 = (𝑋𝑥 − 𝑥𝑖)2+(𝑋𝑦 − 𝑦𝑖)2 Here, K1 = (−1 + 0.125 )2+(−4 − .25)2 =4.33 K2= (−1 + 1)2+(−4 − 4)2 =5 12 CLUSTER X Y CENTROID ASSIGHNMENT K1 (0.125-1)/2 = -.43 (.25-1)/2 = -.375 -.43, -1.85 1 K2 -1 4 -1,4 X Y A 1 2 B 2 2 C 2 1 D -1 4 E -2 -1 F -1 -1
  • 13. Final Clustering & Assignments: 13 X Y ASSIGNMENT A 1 2 1 B 1.5 2 1 C 1.75 1.5 1 D -1 4 1 E .125 .25 1 F -..43 -.375 1
  • 14. 2D Graph: 14 2 2 1 4 -1 -4 -6 -4 -2 0 2 4 6 -3 -2 -1 0 1 2 3 Y-Values 2 2 1.5 4 0.25 -0.375 -2 -1 0 1 2 3 4 5 -2 -1 0 1 2 3 Y-Values AFTER CLUSTERINGBEFORE CLUSTERING
  • 15. Thanks! Any questions? You can find me at: ifirozy@gmail.com 15