SlideShare une entreprise Scribd logo
1  sur  15
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

Contenu connexe

Tendances

Waldie pd2
Waldie pd2Waldie pd2
Waldie pd2guero456
 
January 9, 2015 intro to functions
January 9, 2015 intro to functionsJanuary 9, 2015 intro to functions
January 9, 2015 intro to functionskhyps13
 
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 networksmourya chandra
 
1 illustrating limit of a function
1 illustrating limit of a function1 illustrating limit of a function
1 illustrating limit of a functionJRCatador
 
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 MatlabCOMSATS 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 MATLABCOMSATS 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 SystemCOMSATS Abbottabad
 
8th pre alg -l41
8th pre alg -l418th pre alg -l41
8th pre alg -l41jdurst65
 
Logarithm Bases IA
Logarithm Bases IALogarithm Bases IA
Logarithm Bases IAbank8787
 
Pythagorean theorem and distance formula
Pythagorean theorem and distance formulaPythagorean theorem and distance formula
Pythagorean theorem and distance formula41178582
 
Pythagorean theorem and distance formula
Pythagorean theorem and distance formulaPythagorean theorem and distance formula
Pythagorean theorem and distance formula41178582
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABPranoti 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 computerbikram ...
 

Tendances (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
 

Similaire à 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
 
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 DatasetAlaaZ
 
Lecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptLecture_3_k-mean-clustering.ppt
Lecture_3_k-mean-clustering.pptSyedNahin1
 
Geometry unit 12.5
Geometry unit 12.5Geometry unit 12.5
Geometry unit 12.5Mark Ryder
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structuresKàŕ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 Formulassmiller5
 
K means clustering
K means clusteringK means clustering
K means clusteringAhmedasbasb
 
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 Formulassmiller5
 
11-2-Clustering.pptx
11-2-Clustering.pptx11-2-Clustering.pptx
11-2-Clustering.pptxpaktari1
 
2.1 Rectangular Coordinates
2.1 Rectangular Coordinates2.1 Rectangular Coordinates
2.1 Rectangular Coordinatessmiller5
 
Business analytics course in delhi
Business analytics course in delhiBusiness analytics course in delhi
Business analytics course in delhibhuvan8999
 
data science course in delhi
data science course in delhidata science course in delhi
data science course in delhidevipatnala1
 

Similaire à 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
 

Plus de Iffat Firozy

Association Rule Mining || Data Mining
Association Rule Mining || Data MiningAssociation Rule Mining || Data Mining
Association Rule Mining || Data MiningIffat Firozy
 
Data Preprocessing || Data Mining
Data Preprocessing || Data MiningData Preprocessing || Data Mining
Data Preprocessing || Data MiningIffat 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 TreeIffat Firozy
 
Hidden Markov Model
Hidden Markov ModelHidden Markov Model
Hidden Markov ModelIffat 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 & CGPAIffat Firozy
 

Plus de 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
 

Dernier

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Dernier (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

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