Cluster Kmeans Module
Rust module: cuvs::cluster::kmeans
Source: rust/cuvs/src/cluster/kmeans/mod.rs
K-means clustering.
[fit] computes cluster centroids for a dataset, [predict] assigns points
to clusters, and [cluster_cost] reports the inertia. All inputs and outputs
reside in device memory and are borrowed through the AsDlTensor /
AsDlTensorMut traits; see the dlpack module for the
tensor model.
params::Params
Source: rust/cuvs/src/cluster/kmeans/mod.rs:16
KMeansError
Error type for k-means operations.
Source: rust/cuvs/src/cluster/kmeans/mod.rs:27
fit
Fits k-means centroids to x, returning (inertia, n_iterations).
x (shape m × k) is the input matrix and centroids (shape
n_clusters × k) receives the fitted centroids; sample_weight is an
optional per-sample weight. All reside in device memory and implement
[AsDlTensor] / [AsDlTensorMut].
Source: rust/cuvs/src/cluster/kmeans/mod.rs:45
predict
Assigns each row of x to its nearest centroid, writing cluster labels into
labels and returning the inertia.
x (shape m × k), centroids (shape n_clusters × k), the optional
sample_weight, and labels (shape m × 1) reside in device memory and
implement [AsDlTensor] / [AsDlTensorMut]. normalize_weight selects
whether the sample weights are normalized.
Source: rust/cuvs/src/cluster/kmeans/mod.rs:87
cluster_cost
Computes the k-means cost (inertia) of x against existing centroids.
x (shape m × k) and centroids (shape n_clusters × k) reside in device
memory and implement [AsDlTensor].
Source: rust/cuvs/src/cluster/kmeans/mod.rs:130