SlideShare a Scribd company logo
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
k-means clustering
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
What Will You Learn Today?
Cluster analysisIntroduction to
Machine Learning
Types of clustering
Introduction to k-
means clustering
How k-means
clustering work?
Demo in R: Netflix
use-case
1 2 3
4 65
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
What is Machine learning?
Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without
being explicitly programmed.
Training Data Learn
Algorithm
Build Model Perform
Feedback
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
ML Use Case – Google self driving car
 Google self driving car is a smart, driverless car.
 It collects data from environment through
sensors.
 Takes decisions like when to speed up, when to
speed down, when to overtake and when to
turn.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Types of Machine Learning
Supervised
learning
Unsupervised
learning
Feed the classifier with training data set and predefined labels.
It will learn to categorize particular data under a specific label.
When and where
should I buy a
house?
House features
Area crime rate
Bedrooms
Distance to HQ
Area (in sq.ft)
Locality
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Types of Machine Learning
Supervised
learning
Unsupervised
learning
An image of fruits is first fed into the system.
The system identifies different fruits using features like color, size and it categorizes them.
When a new fruit is shown, it analyses its features and puts it into the category having
similar featured items.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Cluster Analysis
Unsupervised
Learning
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
What is Clustering?
Clustering means grouping of objects based on the information found in the data describing the objects or their
relationship.
 The goal is that objects in one group should be similar to each other but different from objects in another group.
 It deals with finding a structure in a collection of unlabeled data.
Some Examples of clustering methods are:
 K-means Clustering
 Fuzzy/ C-means Clustering
 Hierarchical Clustering
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Clustering Use Cases
Marketing
Seismic studiesLand use
Insurance
Marketing
Discovering distinct groups in customer databases,
such as customers who make lot of long-distance
calls.
Insurance
Identifying groups of crop insurance policy holders
with a high average claim rate. Farmers crash crops,
when it is “profitable”.
Land use
Identification of areas of similar land use in a GIS
database.
Seismic studies
Identifying probable areas for oil/gas exploration
based on seismic data
Use-cases
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Types of clustering
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Types of Clustering
Exclusive Clustering
• An item belongs exclusively to
one cluster, not several.
• K-means does this sort of
exclusive clustering.
• An item can belong to multiple
clusters
• Its degree of association with each
cluster is known
• Fuzzy/ C-means does this sort of
exclusive clustering.
Overlapping Clustering Hierarchial Clustering
• When two cluster have a parent-
child relationship or a tree-like
structure then it is Hierarchical
clustering
Cluster 1
Cluster 2
Cluster 0
Cluster 2
Cluster 1
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
K-means clustering
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
K-means clustering
k-means
clustering
k-means clustering is one of the
simplest algorithms which uses
unsupervised learning method to
solve known clustering issues.
Divides entire dataset into k clusters.
k-means clustering require following
two inputs.
1. K = number of clusters
2. Training set(m) = {x1, x2, x3,......, xm}
Total population
Group 2 Group 3Group 1 Group 4
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Example - Google News
Various news URLs related to Trump and Modi are grouped under one section.
K-means clustering automatically clusters new stories about the same topic into pre-defined clusters.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Example
I need to find specific
locations to build
schools in this area so
that the students
doesn’t have to travel
much
The plot of students in an area is as given below,
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Example - Solution
This looks good
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
But how did he do
that?...
I’ll show you how
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
Choose number of clusters
Initialization
Cluster assignment
Move centroid
Optimization
Convergence
The WSS is defined as the sum of the squared distance between each member of the
cluster and its centroid.
Mathematically:
where, p(i)= data point
q(i)= closest centroid to data point
The idea of the elbow method is to choose the k after which the WSS decrease
is almost constant.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
Choose number of clusters
Initialization
Cluster assignment
Move centroid
Optimization
Convergence
Cluster
centroid
X-axis
Y-axis
Randomly initialize k points called the cluster centroids.
Here, k = 2
Value of k(number of clusters) can be determined by the elbow curve.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
Choose number of clusters
Initialization
Cluster assignment
Move centroid
Optimization
Convergence
 Compute the distance between the data points and the cluster
centroid initialized.
 Depending upon the minimum distance, data points are divided into two
groups.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
Choose number of clusters
Initialization
Cluster assignment
Move centroid
Optimization
Convergence
 Compute the mean of blue dots.
 Reposition blue cluster centroid to this mean.
 Compute the mean of orange dots.
 Reposition orange cluster centroid to this mean.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
Choose number of clusters
Initialization
Cluster assignment
Move centroid
Optimization
Convergence
Repeat previous two steps iteratively till the cluster centroids stop changing their
positions.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
How k-means work?
Choose number of clusters
Initialization
Cluster assignment
Move centroid
Optimization
Convergence
 Finally, k-means clustering algorithm converges.
 Divides the data points into two clusters clearly visible in orange and blue.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Problem Statement
Challenge: Netflix wanted to increase its business by showing most popular movies on its website.
Solution: So, Netflix decided to group the movies based on budget, gross and facebook likes
Approach: For this, Netflix took imdb dataset of 5000 values and applied k-means clustering to group it.
But how would I
know which movie
set to show and
which to not ?
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Demo
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Solution – R Script
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Output
 We got three clusters based on budget and gross.
 Lets see how good are these clusters.
 Using command cl gives following output.
Within cluster sum of squares by cluster:
(between_SS / total _ SS = 72.4 %)
 Higher the %age value, better is the model.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Further, lets relate cluster assignment to individual characteristics like director facebook likes(column 5) and movie
facebook likes(column 28). Cluster 2 has maximum movie likes as well as director likes.
Output
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Try this out
I want to know the profit
values of movie
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Hmm… I will go with cluster
2. It is making maximum
profit and has maximum
facebook likes.
www.edureka.co/data-scienceEdureka’s Data Science Certification Training
Course Details
Go to www.edureka.co/data-science
Get Edureka Certified in Data Science Today!
What our learners have to say about us!
Shravan Reddy says- “I would like to recommend any one who
wants to be a Data Scientist just one place: Edureka. Explanations
are clean, clear, easy to understand. Their support team works
very well.. I took the Data Science course and I'm going to take
Machine Learning with Mahout and then Big Data and Hadoop”.
Gnana Sekhar says - “Edureka Data science course provided me a very
good mixture of theoretical and practical training. LMS pre recorded
sessions and assignments were very good as there is a lot of
information in them that will help me in my job. Edureka is my
teaching GURU now...Thanks EDUREKA.”
Balu Samaga says - “It was a great experience to undergo and get
certified in the Data Science course from Edureka. Quality of the
training materials, assignments, project, support and other
infrastructures are a top notch.”
www.edureka.co/data-scienceEdureka’s Data Science Certification Training

More Related Content

What's hot (20)

PDF
K means Clustering
Edureka!
 
PPTX
K-Nearest Neighbor Classifier
Neha Kulkarni
 
PPTX
K means clustering
keshav goyal
 
PPTX
Classification techniques in data mining
Kamal Acharya
 
PDF
Dimensionality Reduction
mrizwan969
 
PPTX
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
PPTX
CART – Classification & Regression Trees
Hemant Chetwani
 
PPTX
Clustering paradigms and Partitioning Algorithms
Umang MIshra
 
PPTX
Cluster Validation
Udaya Arangala
 
PPTX
05 Clustering in Data Mining
Valerii Klymchuk
 
PPTX
Introduction to Clustering algorithm
hadifar
 
PDF
Information retrieval-systems notes
BAIRAVI T
 
PDF
Linear discriminant analysis
Bangalore
 
PPTX
Hierarchical clustering.pptx
NTUConcepts1
 
PPTX
MODULE 4_ CLUSTERING.pptx
nikshaikh786
 
PDF
From decision trees to random forests
Viet-Trung TRAN
 
PPTX
Classification in data mining
Sulman Ahmed
 
PPTX
Introduction to Linear Discriminant Analysis
Jaclyn Kokx
 
PPTX
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
PPTX
Machine learning clustering
CosmoAIMS Bassett
 
K means Clustering
Edureka!
 
K-Nearest Neighbor Classifier
Neha Kulkarni
 
K means clustering
keshav goyal
 
Classification techniques in data mining
Kamal Acharya
 
Dimensionality Reduction
mrizwan969
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
CART – Classification & Regression Trees
Hemant Chetwani
 
Clustering paradigms and Partitioning Algorithms
Umang MIshra
 
Cluster Validation
Udaya Arangala
 
05 Clustering in Data Mining
Valerii Klymchuk
 
Introduction to Clustering algorithm
hadifar
 
Information retrieval-systems notes
BAIRAVI T
 
Linear discriminant analysis
Bangalore
 
Hierarchical clustering.pptx
NTUConcepts1
 
MODULE 4_ CLUSTERING.pptx
nikshaikh786
 
From decision trees to random forests
Viet-Trung TRAN
 
Classification in data mining
Sulman Ahmed
 
Introduction to Linear Discriminant Analysis
Jaclyn Kokx
 
Machine Learning Tutorial Part - 2 | Machine Learning Tutorial For Beginners ...
Simplilearn
 
Machine learning clustering
CosmoAIMS Bassett
 

Similar to K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm | Edureka (20)

PDF
Data Science Tutorial | What is Data Science? | Data Science For Beginners | ...
Edureka!
 
PPTX
Application of Clustering in Data Science using Real-life Examples
Edureka!
 
PDF
Data Science : Make Smarter Business Decisions
Edureka!
 
PPTX
big data analytics unit 2 notes for study
DIVYADHARSHINISDIVYA
 
PPTX
K MEANS CLUSTERING - UNSUPERVISED LEARNING
PalanivelG6
 
PPTX
Unsupervised Learning: Clustering
Experfy
 
PDF
Business Analytics with R
Edureka!
 
PPTX
Top 5 algorithms used in Data Science
Edureka!
 
PDF
Sentiment Analysis In Retail Domain
Edureka!
 
PDF
Machine Learning, Statistics And Data Mining
Jason J Pulikkottil
 
PPTX
Presentation on K-Means Clustering
Pabna University of Science & Technology
 
PDF
Chapter#04[Part#01]K-Means Clusterig.pdf
MaheenVohra
 
PPTX
ML basic & clustering
monalisa Das
 
PPT
Clustering
DataminingTools Inc
 
PPT
Clustering
Datamining Tools
 
PDF
Unsupervised Learning in Machine Learning
rahuljain582793
 
PDF
Machine Learning, K-means Algorithm Implementation with R
IRJET Journal
 
PPTX
machine learning - Clustering in R
Sudhakar Chavan
 
PPT
Clustering & classification
Jamshed Khan
 
PDF
K-Means Clustering Explained_ Algorithm And Sklearn Implementation _ by Mariu...
christopher corlett
 
Data Science Tutorial | What is Data Science? | Data Science For Beginners | ...
Edureka!
 
Application of Clustering in Data Science using Real-life Examples
Edureka!
 
Data Science : Make Smarter Business Decisions
Edureka!
 
big data analytics unit 2 notes for study
DIVYADHARSHINISDIVYA
 
K MEANS CLUSTERING - UNSUPERVISED LEARNING
PalanivelG6
 
Unsupervised Learning: Clustering
Experfy
 
Business Analytics with R
Edureka!
 
Top 5 algorithms used in Data Science
Edureka!
 
Sentiment Analysis In Retail Domain
Edureka!
 
Machine Learning, Statistics And Data Mining
Jason J Pulikkottil
 
Presentation on K-Means Clustering
Pabna University of Science & Technology
 
Chapter#04[Part#01]K-Means Clusterig.pdf
MaheenVohra
 
ML basic & clustering
monalisa Das
 
Clustering
Datamining Tools
 
Unsupervised Learning in Machine Learning
rahuljain582793
 
Machine Learning, K-means Algorithm Implementation with R
IRJET Journal
 
machine learning - Clustering in R
Sudhakar Chavan
 
Clustering & classification
Jamshed Khan
 
K-Means Clustering Explained_ Algorithm And Sklearn Implementation _ by Mariu...
christopher corlett
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

PPTX
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
PPTX
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PPTX
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PDF
Choosing the Right Database for Indexing.pdf
Tamanna
 
PPTX
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
PDF
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PPTX
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
PPTX
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
PDF
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
PPTX
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
PDF
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
PPTX
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
PDF
Copia de Strategic Roadmap Infographics by Slidesgo.pptx (1).pdf
ssuserd4c6911
 
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
Choosing the Right Database for Indexing.pdf
Tamanna
 
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
Copia de Strategic Roadmap Infographics by Slidesgo.pptx (1).pdf
ssuserd4c6911
 

K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm | Edureka

  • 1. www.edureka.co/data-scienceEdureka’s Data Science Certification Training k-means clustering
  • 2. www.edureka.co/data-scienceEdureka’s Data Science Certification Training What Will You Learn Today? Cluster analysisIntroduction to Machine Learning Types of clustering Introduction to k- means clustering How k-means clustering work? Demo in R: Netflix use-case 1 2 3 4 65
  • 3. www.edureka.co/data-scienceEdureka’s Data Science Certification Training What is Machine learning? Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without being explicitly programmed. Training Data Learn Algorithm Build Model Perform Feedback
  • 4. www.edureka.co/data-scienceEdureka’s Data Science Certification Training ML Use Case – Google self driving car  Google self driving car is a smart, driverless car.  It collects data from environment through sensors.  Takes decisions like when to speed up, when to speed down, when to overtake and when to turn.
  • 5. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Types of Machine Learning Supervised learning Unsupervised learning Feed the classifier with training data set and predefined labels. It will learn to categorize particular data under a specific label. When and where should I buy a house? House features Area crime rate Bedrooms Distance to HQ Area (in sq.ft) Locality
  • 6. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Types of Machine Learning Supervised learning Unsupervised learning An image of fruits is first fed into the system. The system identifies different fruits using features like color, size and it categorizes them. When a new fruit is shown, it analyses its features and puts it into the category having similar featured items.
  • 7. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Cluster Analysis Unsupervised Learning
  • 8. www.edureka.co/data-scienceEdureka’s Data Science Certification Training What is Clustering? Clustering means grouping of objects based on the information found in the data describing the objects or their relationship.  The goal is that objects in one group should be similar to each other but different from objects in another group.  It deals with finding a structure in a collection of unlabeled data. Some Examples of clustering methods are:  K-means Clustering  Fuzzy/ C-means Clustering  Hierarchical Clustering
  • 9. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Clustering Use Cases Marketing Seismic studiesLand use Insurance Marketing Discovering distinct groups in customer databases, such as customers who make lot of long-distance calls. Insurance Identifying groups of crop insurance policy holders with a high average claim rate. Farmers crash crops, when it is “profitable”. Land use Identification of areas of similar land use in a GIS database. Seismic studies Identifying probable areas for oil/gas exploration based on seismic data Use-cases
  • 10. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Types of clustering
  • 11. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Types of Clustering Exclusive Clustering • An item belongs exclusively to one cluster, not several. • K-means does this sort of exclusive clustering. • An item can belong to multiple clusters • Its degree of association with each cluster is known • Fuzzy/ C-means does this sort of exclusive clustering. Overlapping Clustering Hierarchial Clustering • When two cluster have a parent- child relationship or a tree-like structure then it is Hierarchical clustering Cluster 1 Cluster 2 Cluster 0 Cluster 2 Cluster 1
  • 12. www.edureka.co/data-scienceEdureka’s Data Science Certification Training K-means clustering
  • 13. www.edureka.co/data-scienceEdureka’s Data Science Certification Training K-means clustering k-means clustering k-means clustering is one of the simplest algorithms which uses unsupervised learning method to solve known clustering issues. Divides entire dataset into k clusters. k-means clustering require following two inputs. 1. K = number of clusters 2. Training set(m) = {x1, x2, x3,......, xm} Total population Group 2 Group 3Group 1 Group 4
  • 14. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Example - Google News Various news URLs related to Trump and Modi are grouped under one section. K-means clustering automatically clusters new stories about the same topic into pre-defined clusters.
  • 15. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Example I need to find specific locations to build schools in this area so that the students doesn’t have to travel much The plot of students in an area is as given below,
  • 16. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Example - Solution This looks good
  • 17. www.edureka.co/data-scienceEdureka’s Data Science Certification Training But how did he do that?... I’ll show you how
  • 18. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work?
  • 19. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work? Choose number of clusters Initialization Cluster assignment Move centroid Optimization Convergence The WSS is defined as the sum of the squared distance between each member of the cluster and its centroid. Mathematically: where, p(i)= data point q(i)= closest centroid to data point The idea of the elbow method is to choose the k after which the WSS decrease is almost constant.
  • 20. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work? Choose number of clusters Initialization Cluster assignment Move centroid Optimization Convergence Cluster centroid X-axis Y-axis Randomly initialize k points called the cluster centroids. Here, k = 2 Value of k(number of clusters) can be determined by the elbow curve.
  • 21. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work? Choose number of clusters Initialization Cluster assignment Move centroid Optimization Convergence  Compute the distance between the data points and the cluster centroid initialized.  Depending upon the minimum distance, data points are divided into two groups.
  • 22. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work? Choose number of clusters Initialization Cluster assignment Move centroid Optimization Convergence  Compute the mean of blue dots.  Reposition blue cluster centroid to this mean.  Compute the mean of orange dots.  Reposition orange cluster centroid to this mean.
  • 23. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work? Choose number of clusters Initialization Cluster assignment Move centroid Optimization Convergence Repeat previous two steps iteratively till the cluster centroids stop changing their positions.
  • 24. www.edureka.co/data-scienceEdureka’s Data Science Certification Training How k-means work? Choose number of clusters Initialization Cluster assignment Move centroid Optimization Convergence  Finally, k-means clustering algorithm converges.  Divides the data points into two clusters clearly visible in orange and blue.
  • 25. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Problem Statement Challenge: Netflix wanted to increase its business by showing most popular movies on its website. Solution: So, Netflix decided to group the movies based on budget, gross and facebook likes Approach: For this, Netflix took imdb dataset of 5000 values and applied k-means clustering to group it. But how would I know which movie set to show and which to not ?
  • 27. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Solution – R Script
  • 28. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Output  We got three clusters based on budget and gross.  Lets see how good are these clusters.  Using command cl gives following output. Within cluster sum of squares by cluster: (between_SS / total _ SS = 72.4 %)  Higher the %age value, better is the model.
  • 29. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Further, lets relate cluster assignment to individual characteristics like director facebook likes(column 5) and movie facebook likes(column 28). Cluster 2 has maximum movie likes as well as director likes. Output
  • 30. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Try this out I want to know the profit values of movie
  • 31. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Hmm… I will go with cluster 2. It is making maximum profit and has maximum facebook likes.
  • 32. www.edureka.co/data-scienceEdureka’s Data Science Certification Training Course Details Go to www.edureka.co/data-science Get Edureka Certified in Data Science Today! What our learners have to say about us! Shravan Reddy says- “I would like to recommend any one who wants to be a Data Scientist just one place: Edureka. Explanations are clean, clear, easy to understand. Their support team works very well.. I took the Data Science course and I'm going to take Machine Learning with Mahout and then Big Data and Hadoop”. Gnana Sekhar says - “Edureka Data science course provided me a very good mixture of theoretical and practical training. LMS pre recorded sessions and assignments were very good as there is a lot of information in them that will help me in my job. Edureka is my teaching GURU now...Thanks EDUREKA.” Balu Samaga says - “It was a great experience to undergo and get certified in the Data Science course from Edureka. Quality of the training materials, assignments, project, support and other infrastructures are a top notch.”

Editor's Notes