Skip to main content

StatisticalFieldAnomalyDetector

Struct StatisticalFieldAnomalyDetector 

Source
pub struct StatisticalFieldAnomalyDetector {
    pub window_size: usize,
    pub iqr_multiplier: f64,
    pub jaccard_threshold: f64,
    pub staleness_threshold_secs: i64,
    pub z_score_threshold: f64,
    pub cardinality_shift_fraction: f64,
    /* private fields */
}
Expand description

Default statistical detector. Rolling-window-based: keeps the last Self::WINDOW_SIZE observations per field per schema and applies the five heuristics in AnomalySignal.

Fields§

§window_size: usize

Sliding-window size for each (schema, field) pair.

§iqr_multiplier: f64

IQR multiplier for AnomalySignal::PriceDrift. Default 3.0.

§jaccard_threshold: f64

Jaccard-distance threshold for AnomalySignal::ListingReorder. Default 0.3.

§staleness_threshold_secs: i64

Staleness threshold in seconds for AnomalySignal::Staleness. Default 7 days.

§z_score_threshold: f64

z-score threshold for AnomalySignal::Outlier. Default 3.0.

§cardinality_shift_fraction: f64

Cardinality-shift threshold as a fraction (0.5 = 50%).

Implementations§

Source§

impl StatisticalFieldAnomalyDetector

Source

pub const WINDOW_SIZE: usize = 64

Default sliding-window size.

Source

pub fn new() -> Self

Construct a new detector with the default tuning constants.

Trait Implementations§

Source§

impl Debug for StatisticalFieldAnomalyDetector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StatisticalFieldAnomalyDetector

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FieldAnomalyDetector for StatisticalFieldAnomalyDetector

Source§

fn name(&self) -> &'static str

Stable name for diagnostics.
Source§

fn observe<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, schema_id: &'life1 SchemaId, field: &'life2 FieldPath, value: &'life3 FieldValue, ) -> Pin<Box<dyn Future<Output = Result<AnomalyReport, AnomalyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Observe one field value. Returns AnomalyReport::signal describing any anomaly detected, or AnomalySignal::None if the value is consistent with the rolling baseline. Read more
Source§

fn baseline<'life0, 'life1, 'async_trait>( &'life0 self, schema_id: &'life1 SchemaId, ) -> Pin<Box<dyn Future<Output = Result<SchemaBaseline, AnomalyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return the current baseline for a schema.
Source§

fn reset<'life0, 'life1, 'async_trait>( &'life0 self, schema_id: &'life1 SchemaId, ) -> Pin<Box<dyn Future<Output = Result<(), AnomalyError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Drop the rolling state for a schema. Used by callers that want to force a fresh baseline (e.g. after a backfill).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more