pub struct EmbeddingDriftDetector {
pub id: String,
pub config: DetectorConfig,
/* private fields */
}Expand description
Detects concept drift in a stream of high-dimensional embeddings.
Maintains a rolling window and a reference window; when the rolling window
fills it is compared to the reference window using the configured
DetectionMethod.
Fields§
§id: StringDetector identifier (used in emitted DriftSignal values).
config: DetectorConfigConfiguration.
Implementations§
Source§impl EmbeddingDriftDetector
impl EmbeddingDriftDetector
Sourcepub fn new(config: DetectorConfig) -> Self
pub fn new(config: DetectorConfig) -> Self
Creates a new detector with the given configuration.
Sourcepub fn with_id(id: impl Into<String>, config: DetectorConfig) -> Self
pub fn with_id(id: impl Into<String>, config: DetectorConfig) -> Self
Creates a new detector with a custom string identifier.
Sourcepub fn add_sample(
&mut self,
embedding: Vec<f64>,
timestamp: u64,
) -> Result<Option<DriftSignal>, DetectorError>
pub fn add_sample( &mut self, embedding: Vec<f64>, timestamp: u64, ) -> Result<Option<DriftSignal>, DetectorError>
Adds one embedding to the rolling window.
Returns Ok(Some(signal)) when drift is detected, Ok(None) otherwise.
Sourcepub fn take_snapshot(
&mut self,
timestamp: u64,
) -> Result<DriftSnapshot, DetectorError>
pub fn take_snapshot( &mut self, timestamp: u64, ) -> Result<DriftSnapshot, DetectorError>
Computes a snapshot of the current rolling window.
Sourcepub fn compare_snapshots(
&self,
reference: &DriftSnapshot,
current: &DriftSnapshot,
) -> Result<DriftSignal, DetectorError>
pub fn compare_snapshots( &self, reference: &DriftSnapshot, current: &DriftSnapshot, ) -> Result<DriftSignal, DetectorError>
Compares two snapshots using the configured DetectionMethod.
Returns a DriftSignal whose magnitude is 0.0 if no drift was
detected, and positive otherwise.
Sourcepub fn reset_reference(&mut self) -> Result<(), DetectorError>
pub fn reset_reference(&mut self) -> Result<(), DetectorError>
Copies the current rolling window into the reference window.
Sourcepub fn drift_history(&self) -> Vec<DriftSignal>
pub fn drift_history(&self) -> Vec<DriftSignal>
Returns the last 100 drift signals (oldest first).
Sourcepub fn stats(&self) -> DriftStats
pub fn stats(&self) -> DriftStats
Returns aggregate statistics for this detector.
Sourcepub fn window_len(&self) -> usize
pub fn window_len(&self) -> usize
Returns the number of samples in the rolling window.
Sourcepub fn reference_len(&self) -> usize
pub fn reference_len(&self) -> usize
Returns the number of samples in the reference window.
Sourcepub fn embedding_dim(&self) -> Option<usize>
pub fn embedding_dim(&self) -> Option<usize>
Returns the established embedding dimension (if any sample has been added).
Sourcepub fn random_f64(&mut self) -> f64
pub fn random_f64(&mut self) -> f64
Draws a pseudo-random f64 from the internal PRNG.
Auto Trait Implementations§
impl Freeze for EmbeddingDriftDetector
impl RefUnwindSafe for EmbeddingDriftDetector
impl Send for EmbeddingDriftDetector
impl Sync for EmbeddingDriftDetector
impl Unpin for EmbeddingDriftDetector
impl UnsafeUnpin for EmbeddingDriftDetector
impl UnwindSafe for EmbeddingDriftDetector
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.