struct Clustering : public faiss::ClusteringParameters
K-means clustering based on assignment - centroid update iterations
The clustering is based on an Index object that assigns training points to the centroids. Therefore, at each iteration the centroids are added to the index.
On output, the centoids table is set to the latest version of the centroids and they are also added to the index. If the centroids table it is not empty on input, it is also used for initialization.
Subclassed by faiss::Clustering1D
Clustering(int d, int k)
Clustering(int d, int k, const ClusteringParameters &cp)
virtual void train(idx_t n, const float *x, faiss::Index &index, const float *x_weights = nullptr)
run k-means training
x – training vectors, size n * d
index – index used for assignment
x_weights – weight associated to each vector: NULL or size n
void train_encoded(idx_t nx, const uint8_t *x_in, const Index *codec, Index &index, const float *weights = nullptr)
run with encoded vectors
win addition to train()’s parameters takes a codec as parameter to decode the input vectors.
codec – codec used to decode the vectors (nullptr = vectors are in fact floats) *
Post-process the centroids after each centroid update. includes optional L2 normalization and nearest integer rounding
inline virtual ~Clustering()
dimension of the vectors
nb of centroids
centroids (k * d) if centroids are set on input to train, they will be used as initialization
stats at every iteration of clustering
redo clustering this many times and keep best
do we want normalized centroids?
round centroids coordinates to integer
re-train index after each iteration?
use the centroids provided as input and do not change them during iterations
otherwise you get a warning
to limit size of dataset
seed for the random number generator
how many vectors at a time to decode
- Clustering(int d, int k)