pub struct KMeans {
pub centroids: Vec<Vec<f32>>,
pub dimension: usize,
pub iterations: usize,
pub inertia: f32,
}Expand description
K-means clustering result.
Fields§
§centroids: Vec<Vec<f32>>The cluster centroids.
dimension: usizeThe dimension of each centroid.
iterations: usizeNumber of iterations run.
inertia: f32Final inertia (sum of squared distances to nearest centroid).
Implementations§
Source§impl KMeans
impl KMeans
Sourcepub fn train(
data: &[&[f32]],
config: &KMeansConfig,
metric: DistanceMetric,
) -> Result<Self, VectorError>
pub fn train( data: &[&[f32]], config: &KMeansConfig, metric: DistanceMetric, ) -> Result<Self, VectorError>
Sourcepub fn find_nearest(&self, vector: &[f32], metric: DistanceMetric) -> usize
pub fn find_nearest(&self, vector: &[f32], metric: DistanceMetric) -> usize
Find the index of the nearest centroid to the given vector.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KMeans
impl RefUnwindSafe for KMeans
impl Send for KMeans
impl Sync for KMeans
impl Unpin for KMeans
impl UnwindSafe for KMeans
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more