pub struct Adwin { /* private fields */ }Expand description
ADWIN drift detector for streaming data.
§Example
use scirs2_transform::monitoring::adwin::Adwin;
let mut adwin = Adwin::new(0.002).expect("valid delta");
// Feed stable data
for i in 0..100 {
adwin.add_element(1.0 + (i as f64) * 0.001).expect("add");
}
// Feed shifted data
for _ in 0..100 {
let changed = adwin.add_element(50.0).expect("add");
if changed {
// Drift detected!
break;
}
}Implementations§
Source§impl Adwin
impl Adwin
Sourcepub fn new(delta: f64) -> Result<Self>
pub fn new(delta: f64) -> Result<Self>
Create a new ADWIN detector.
delta– confidence parameter in (0, 1). Smaller values make the detector less sensitive (fewer false positives, slower reaction). Typical values: 0.002 (default in MOA), 0.01, 0.05.
Sourcepub fn set_min_window_length(&mut self, min_len: usize)
pub fn set_min_window_length(&mut self, min_len: usize)
Set the minimum window length before drift checks begin.
Sourcepub fn add_element(&mut self, value: f64) -> Result<bool>
pub fn add_element(&mut self, value: f64) -> Result<bool>
Add an element to the window and check for change.
Returns true if a distribution change was detected (window was shrunk).
Sourcepub fn detected_change(&self) -> bool
pub fn detected_change(&self) -> bool
Whether the last call to add_element detected a change.
Sourcepub fn current_mean(&self) -> f64
pub fn current_mean(&self) -> f64
Current mean of the window.
Sourcepub fn current_length(&self) -> usize
pub fn current_length(&self) -> usize
Current number of elements in the window.
Sourcepub fn current_sum(&self) -> f64
pub fn current_sum(&self) -> f64
Current sum of all elements in the window.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Adwin
impl RefUnwindSafe for Adwin
impl Send for Adwin
impl Sync for Adwin
impl Unpin for Adwin
impl UnsafeUnpin for Adwin
impl UnwindSafe for Adwin
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.