@standardbeagle/ux-core - v0.1.0
    Preparing search index...

    Function kmeans

    • k-means clustering with k-means++ initialization and Lloyd iteration.

      Runs at most maxIterations Lloyd passes and stops early once no centroid shifts by more than tolerance Euclidean distance. Empty input or k <= 0 returns []. If k exceeds points.length, it is clamped down.

      Parameters

      • points: Point[]

        Input points to cluster.

      • k: number

        Target number of clusters.

      • maxIterations: number = 50

        Hard cap on Lloyd passes (default 50).

      • tolerance: number = 1.0

        Centroid-shift threshold for early termination (default 1.0).

      Returns Cluster[]

      Array of Clusters with populated centroid and empty points.