pub struct SemanticClusterAnalyzer {
pub points: Vec<ClusterPoint>,
pub clusters: Vec<Cluster>,
pub config: AnalyzerConfig,
}Expand description
Performs k-means++ style cluster analysis over a set of embedding vectors.
Initialization is deterministic (k-means++ greedy farthest-point selection, no randomness), which means results are reproducible given the same input order.
Fields§
§points: Vec<ClusterPoint>All managed points.
clusters: Vec<Cluster>Clusters produced by the most recent run_kmeans call.
config: AnalyzerConfigAnalyzer configuration.
Implementations§
Source§impl SemanticClusterAnalyzer
impl SemanticClusterAnalyzer
Sourcepub fn new(config: AnalyzerConfig) -> Self
pub fn new(config: AnalyzerConfig) -> Self
Create a new analyzer with the given configuration.
Sourcepub fn run_kmeans(&mut self, k: usize) -> ClusterStats
pub fn run_kmeans(&mut self, k: usize) -> ClusterStats
Run k-means clustering with k clusters.
§Initialization (deterministic k-means++ style)
- First centroid =
points[0].vector. - Each subsequent centroid = the point whose minimum distance to any already-chosen centroid is the largest (greedy farthest-point).
§Iteration
Assign → recompute → check convergence (or max_iterations reached).
Returns a default ClusterStats when k == 0, points is empty,
or k > points.len().
Sourcepub fn outliers(&self, factor: f64) -> Vec<u64>
pub fn outliers(&self, factor: f64) -> Vec<u64>
Return IDs of points whose distance to their centroid exceeds
factor * avg_intra_distance.
If there are no assigned points the list is empty.
Sourcepub fn nearest_cluster(&self, query: &[f32]) -> Option<usize>
pub fn nearest_cluster(&self, query: &[f32]) -> Option<usize>
Return the cluster id of the nearest centroid to query,
or None when no clusters exist.
Sourcepub fn stats(&self) -> ClusterStats
pub fn stats(&self) -> ClusterStats
Return cluster statistics for the current state.
Returns a default ClusterStats when no clusters have been computed.
Auto Trait Implementations§
impl Freeze for SemanticClusterAnalyzer
impl RefUnwindSafe for SemanticClusterAnalyzer
impl Send for SemanticClusterAnalyzer
impl Sync for SemanticClusterAnalyzer
impl Unpin for SemanticClusterAnalyzer
impl UnsafeUnpin for SemanticClusterAnalyzer
impl UnwindSafe for SemanticClusterAnalyzer
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.