K Means Clustering
K Means Clustering
Dr.J.Jeyaboopathiraja
Assistant Professor
Department of Computer Science
Sri Ramakrishna College of Arts & Science
Coimbatore
Machine Learning is broadly classified into Supervised and Unsupervised
Learning based on how the model learns from data.
Supervised Learning
🔹 Definition: The model is trained on labeled data, meaning each input has a
corresponding output.
🔹 Goal: Learn from the past data and make predictions on new data.
🔹 Types:
Classification (Predict categories) → e.g., Spam or Not Spam
Unsupervised Learning
Collect Data
Suppose we have a dataset with two key features for each customer:
Annual Income (in $1000s)
Spending Score (1–100) (how much they spend compared to their
income)
Initialize Centroids
Randomly select 3 points as initial centroids.
Let's assume:
Centroid 1: (15, 80)
Centroid 2: (40, 50)
Centroid 3: (80, 20)
Step 1: Choose the Number of Clusters (K)
The value of K (number of clusters) is chosen manually or using the
Elbow Method.
Here, we assume K = 3, meaning we divide customers into 3 groups.