K-Means Clustering

K-Means Clustering Lab

Voronoi regions, centroid updates और inertia tracking के साथ इंटरैक्टिव 2D clustering सिमुलेटर।

K-Means डेटा को K clusters में बांटता है और within-cluster squared distance (inertia) को न्यूनतम करता है।

$$ J = \sum_{i=1}^{N} \min_{1 \leq j \leq K} \left\lVert x_i - \mu_j \right\rVert^2 $$

हर sample सबसे नज़दीकी centroid को assign होता है, फिर centroids को assigned samples की mean से recompute किया जाता है।

Algorithm दो deterministic steps के बीच चलता है:

$$ c_i \leftarrow \arg\min_j \lVert x_i - \mu_j \rVert^2 $$

$$ \mu_j \leftarrow \frac{1}{|C_j|}\sum_{x_i \in C_j} x_i $$

Inertia monotonically घटती है जब तक local optimum पर converge न हो जाए।

Random initialization सरल है लेकिन खराब seeds से शुरू हो सकता है।

k-means++ प्रारंभिक centroids फैलाता है, जिससे अक्सर तेज convergence और कम final inertia मिलती है।

Production में अलग-अलग seeds के साथ multiple runs करें ताकि local-minimum sensitivity कम हो।

  1. Demo points लोड करें, फिर Random vs k-means++ initialization तुलना करें।
  2. अलग-अलग K values आज़माएं और region boundaries व cluster counts देखें।
  3. Step से एक assign/update cycle एक समय में देखें।
  4. Convergence तक चलाएं और final inertia values तुलना करें।

Canvas पर कहीं भी क्लिक करके points जोड़ें। Touch पर long-press या right-click से nearest point हटाएं।

Status
Points: 0
K: 3
Iteration: 0
Inertia: -
Centroid Shift: -
Inertia Curve
Cluster Summary