> ## Documentation Index
> Fetch the complete documentation index at: https://shapely.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# K-Means

>  K-Means partitions data into K distinct groups by minimizing the distance between data points and their assigned cluster center (centroid). It is one of the simplest and most widely used clustering algorithms.

It works by iteratively assigning points to the nearest centroid and repositioning centroids until they stabilize. 

<Note>
  K-Means requires you to specify the number of clusters (**K**) in advance. Use the **K-Finder** analysis node to automatically determine the optimal K value for your data.
</Note>

### Use Cases

* **Spatial grouping**: Group building elements or rooms by their geometric properties (area, centroid location) into meaningful clusters.
* **Urban block partitioning**: Divide urban areas into K zones based on spatial features.

<a href="/images/ML/K-Means.png" target="_blank">
  <img src="https://mintcdn.com/shapely/k8EK4RW_OYOqKd74/images/ML/K-Means.png?fit=max&auto=format&n=k8EK4RW_OYOqKd74&q=85&s=7c24fdfec3468cf493fc6a9bd3a6b8bc" className="pointer-events-none" style={{ borderRadius: '0.5rem', border: '1px solid rgba(0,0,0,0.1)' }} width="2011" height="1046" data-path="images/ML/K-Means.png" />
</a>

### An example of test

<Frame>
  <a href="https://github.com/DurmusCesur/docs/releases/download/ML/Machine.Learning.rvt" download="Machine Learning.rvt">
    <button className="bg-gradient-to-r from-blue-600 via-blue-450 to-blue-600 text-white px-6 py-1 rounded-lg shadow-lg hover:bg-gradient-to-l hover:from-blue-500 hover:to-blue-400 transition-all">
      Machine Learning - RVT2026.rvt
    </button>
  </a>
</Frame>

<Frame>
  <a href="https://github.com/DurmusCesur/docs/releases/download/ML-Dyn/Kmeans-GroupWalls.dyn" download="K-Means.dyn">
    <button className="bg-[#16A34A] text-white px-5 py-1 rounded-md hover:bg-[#15803D] transition-colors">
      K-Means.dyn
    </button>
  </a>
</Frame>
