Skip to contents

Perform K-means clustering using the FAISS Python library

Usage

faiss_kmeans(
  data_matrix,
  k,
  niter = 20,
  verbose = TRUE,
  n_cores = parallel::detectCores() - 1
)

Arguments

data_matrix

Numeric matrix: Input dataset where each row is a sample and each column is a feature.

k

Integer: The desired number of clusters (centroids).

niter

Integer: Number of K-means training iterations (default: 20).

verbose

Logical: Whether to display clustering progress and loss details during training (default: TRUE).

n_cores

Integer: Number of CPU threads to use for execution (default: number of available cores minus 1).

Value

A FAISS K-means object containing cluster centroids and assignment details.

Examples

if (FALSE) { # \dontrun{
  mat <- matrix(runif(1000 * 10), nrow = 1000, ncol = 10)
  res <- faiss_kmeans(data_matrix = mat, k = 5, niter = 25)
} # }