Page10/20
Unsupervised Learning & K-Means Β· Page 1 of 1
Clustering Intuition
Unsupervised Learning & K-Means
No Labels? No Problem.
In Supervised learning, we have targets (y). In Unsupervised learning, we only have features (X). The algorithm must find hidden structure on its own.
What is K-Means?
K-Means groups data into 'K' distinct clusters based on feature similarity.
- Randomly place 'K' centroids.
- Assign every data point to its nearest centroid.
- Move the centroids to the exact center (mean) of their assigned points.
- Repeat steps 2 & 3 until the centroids stop moving.
Choosing K
How do you know how many clusters exist?
- Domain Knowledge: (e.g., "I want to segment customers into 3 tiers").
- The Elbow Method: Plot the total distance from points to their centroids. When the line looks like an "elbow", that's usually the right K.
main.py
Loading...
OUTPUT
βΆClick "Run Code" to executeβ¦