pub struct SemanticCluster {
pub cluster_id: usize,
pub centroid: Vec<f32>,
pub member_count: u64,
pub total_drift: f32,
}Expand description
A single semantic cluster with a centroid maintained via incremental updates.
Fields§
§cluster_id: usizeCluster index (0-based).
centroid: Vec<f32>Current centroid vector (mean embedding direction).
member_count: u64Number of documents that have been assigned to and updated this cluster.
total_drift: f32Cumulative Euclidean shift of the centroid across all updates.
Implementations§
Source§impl SemanticCluster
impl SemanticCluster
Sourcepub fn euclidean_distance(&self, embedding: &[f32]) -> f32
pub fn euclidean_distance(&self, embedding: &[f32]) -> f32
Compute Euclidean distance between the centroid and embedding.
Returns 0.0 if either vector is empty or if the dimensions differ.
Sourcepub fn update_centroid(&mut self, new_embedding: &[f32], learning_rate: f32)
pub fn update_centroid(&mut self, new_embedding: &[f32], learning_rate: f32)
Update the centroid toward new_embedding using an exponential moving average.
Formula: centroid[i] = (1 - learning_rate) * centroid[i] + learning_rate * new_embedding[i]
Computes the drift (Euclidean shift of the centroid) and adds it to total_drift.
Increments member_count by one.
This is a no-op if the dimensions of new_embedding do not match the centroid.
Trait Implementations§
Source§impl Clone for SemanticCluster
impl Clone for SemanticCluster
Source§fn clone(&self) -> SemanticCluster
fn clone(&self) -> SemanticCluster
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SemanticCluster
impl RefUnwindSafe for SemanticCluster
impl Send for SemanticCluster
impl Sync for SemanticCluster
impl Unpin for SemanticCluster
impl UnsafeUnpin for SemanticCluster
impl UnwindSafe for SemanticCluster
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.