Trait kmeans_colors::Hamerly
source · 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§
sourcefn compute_half_distances(centroids: &mut HamerlyCentroids<Self>)
fn compute_half_distances(centroids: &mut HamerlyCentroids<Self>)
Find the nearest centers and compute their half-distances.
sourcefn get_closest_centroid_hamerly(
buffer: &[Self],
centroids: &HamerlyCentroids<Self>,
indices: &mut [HamerlyPoint]
)
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.
sourcefn recalculate_centroids_hamerly(
rng: &mut impl Rng,
buf: &[Self],
centroids: &mut HamerlyCentroids<Self>,
points: &[HamerlyPoint]
)
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.
sourcefn update_bounds(
centroids: &HamerlyCentroids<Self>,
points: &mut [HamerlyPoint]
)
fn update_bounds( centroids: &HamerlyCentroids<Self>, points: &mut [HamerlyPoint] )
Update the lower and upper bounds of each point.