Find the groups hiding in your data.
Direct answer
Clustering groups similar data points without labels. In k-means, you choose the number of groups k, and the algorithm repeatedly assigns points to the nearest centre and moves the centres until groups stabilise. It is used for customer segments, topic grouping and anomaly spotting.
Example
from sklearn.cluster import KMeans
import numpy as np
X = np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]])
model = KMeans(n_clusters=2, n_init=10, random_state=0).fit(X)
print(model.labels_)
Choosing k
- Elbow method: plot error against k and look for a bend.
- Silhouette score: higher means better separated groups.
- Practical meaning: do the groups make sense?
Cautions
- Scale features first.
- Results depend on starting points, so run several.
- Clusters are not always meaningful.
Where Teyro fits
Teyro's Machine Learning for Beginners course turns this into short lessons you can play in a few minutes a day. It has 200 lessons, and you can start free.
The bottom line
Clustering finds patterns. You decide whether they matter.



