Clustering
C++20 header-only: DBSCAN, HDBSCAN, k-means.
Loading...
Searching...
No Matches
clustering::kmeans::GreedyKmppSeeder< T > Class Template Reference

Greedy k-means++ seeder. More...

#include <clustering/kmeans/policy/greedy_kmpp_seeder.h>

Public Member Functions

 GreedyKmppSeeder ()
void run (const NDArray< T, 2, Layout::Contig > &X, std::size_t k, std::uint64_t seed, math::Pool pool, NDArray< T, 2, Layout::Contig > &outCentroids)
 Seed k centroids from X into outCentroids.

Detailed Description

template<class T>
class clustering::kmeans::GreedyKmppSeeder< T >

Greedy k-means++ seeder.

Picks k initial centroid rows from the dataset. The first centroid is drawn uniformly; each subsequent centroid is the best of L = 2 + floor(ln(k)) candidates sampled with probability proportional to D(x)^2 – the squared distance from each point to its nearest already-chosen centroid. The candidate that yields the smallest resulting sum of squared minimum distances wins.

Scratch is private: the candidate pack, the transposed candidate layout, the per-point per-candidate distance cache, the cumulative-distance array, and the per-point running min-squared-distance all live inside the policy. Repeated run calls at a stable (n, d, k) shape pay no reallocation.

Template Parameters
TElement type; float or double.

Definition at line 317 of file greedy_kmpp_seeder.h.

Constructor & Destructor Documentation

◆ GreedyKmppSeeder()

template<class T>
clustering::kmeans::GreedyKmppSeeder< T >::GreedyKmppSeeder ( )
inline

Definition at line 322 of file greedy_kmpp_seeder.h.

Member Function Documentation

◆ run()

template<class T>
void clustering::kmeans::GreedyKmppSeeder< T >::run ( const NDArray< T, 2, Layout::Contig > & X,
std::size_t k,
std::uint64_t seed,
math::Pool pool,
NDArray< T, 2, Layout::Contig > & outCentroids )
inline

Seed k centroids from X into outCentroids.

Parameters
XData matrix (n x d), contiguous.
kNumber of centroids to seed (>= 1).
seedRNG seed; identical seed + (X, k) produces identical centroids.
poolParallelism injection. Reserved for a future per-chunk fan-out of the scoring loop.
outCentroidsOutput centroid matrix (k x d), contiguous; populated in row order.

Definition at line 337 of file greedy_kmpp_seeder.h.


The documentation for this class was generated from the following file: