pub trait Hamerly: Calculate {
    // Required methods
    fn compute_half_distances(centroids: &mut HamerlyCentroids<Self>);
    fn get_closest_centroid_hamerly(
        buffer: &[Self],
        centroids: &HamerlyCentroids<Self>,
        indices: &mut [HamerlyPoint]
    );
    fn recalculate_centroids_hamerly(
        rng: &mut impl Rng,
        buf: &[Self],
        centroids: &mut HamerlyCentroids<Self>,
        points: &[HamerlyPoint]
    );
    fn update_bounds(
        centroids: &HamerlyCentroids<Self>,
        points: &mut [HamerlyPoint]
    );
}
Expand description

A trait for calculating k-means with the Hamerly algorithm.

Required Methods§

source

fn compute_half_distances(centroids: &mut HamerlyCentroids<Self>)

Find the nearest centers and compute their half-distances.

source

fn get_closest_centroid_hamerly( buffer: &[Self], centroids: &HamerlyCentroids<Self>, indices: &mut [HamerlyPoint] )

Find a point’s nearest centroid, index the point with that centroid.

source

fn recalculate_centroids_hamerly( rng: &mut impl Rng, buf: &[Self], centroids: &mut HamerlyCentroids<Self>, points: &[HamerlyPoint] )

Find the new centroid locations based on the average of the points that correspond to the centroid. If no points correspond, the centroid is re-initialized with a random point.

source

fn update_bounds( centroids: &HamerlyCentroids<Self>, points: &mut [HamerlyPoint] )

Update the lower and upper bounds of each point.

Implementations on Foreign Types§

source§

impl<Wp, T> Hamerly for Lab<Wp, T>where T: Float + FromPrimitive + Zero, Lab<Wp, T>: AddAssign<Lab<Wp, T>> + Default,

source§

fn compute_half_distances(centers: &mut HamerlyCentroids<Self>)

source§

fn get_closest_centroid_hamerly( buffer: &[Self], centers: &HamerlyCentroids<Self>, points: &mut [HamerlyPoint] )

source§

fn recalculate_centroids_hamerly( rng: &mut impl Rng, buf: &[Self], centers: &mut HamerlyCentroids<Self>, points: &[HamerlyPoint] )

source§

fn update_bounds(centers: &HamerlyCentroids<Self>, points: &mut [HamerlyPoint])

source§

impl<S, T> Hamerly for Rgb<S, T>where T: Float + FromPrimitive + Zero, Rgb<S, T>: AddAssign<Rgb<S, T>> + Default,

source§

fn compute_half_distances(centers: &mut HamerlyCentroids<Self>)

source§

fn get_closest_centroid_hamerly( buffer: &[Self], centers: &HamerlyCentroids<Self>, points: &mut [HamerlyPoint] )

source§

fn recalculate_centroids_hamerly( rng: &mut impl Rng, buf: &[Self], centers: &mut HamerlyCentroids<Self>, points: &[HamerlyPoint] )

source§

fn update_bounds(centers: &HamerlyCentroids<Self>, points: &mut [HamerlyPoint])

Implementors§