Algorithm Explorer
Unsupervised Learning Algorithms
How AI discovers hidden patterns without being given the answers.
K-Means Clustering
Analogy
"Like sorting a pile of mixed fruit into groups by shape and color — without being told what the groups are."
How it Works
Assigns data points to K clusters based on similarity. Iteratively moves cluster centres until they stabilize.
Use Cases
Customer segmentation, document grouping, anomaly detection.
In Unsupervised learning, the machine looks at data that has no labels. It's like organizing a messy room without being told where things go.
2. PCA & Apriori
PCA simplifies complex data. Apriori finds associations (e.g., people who buy milk also buy eggs).
1. K-Means Clustering
Groups data points into 'K' clusters by minimizing the distance between points and the center of their assigned cluster.
Python: K-Means Clustering
Grouping points into 2 clusters using scikit-learn:
python
from sklearn.cluster import KMeans
import numpy as np
# Unlabeled points (x, y coordinates)
X = np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]])
kmeans = KMeans(n_clusters=2, random_state=0)
kmeans.fit(X)
print(f"Cluster centers: \n{kmeans.cluster_centers_}")
print(f"Labels for data: {kmeans.labels_}")