pub struct PageHinkley { /* private fields */ }Expand description
Page-Hinkley sequential change detector.
Detects sustained mean shifts in a scalar stream. See the module documentation for the algorithm.
§Examples
use rill_ml::drift::{DriftDetector, DriftLevel, PageHinkley};
let mut ph = PageHinkley::default();
// Stable stream: no drift.
for _ in 0..200 {
ph.update(0.0).unwrap();
}
assert_eq!(ph.level(), DriftLevel::None);
// Sudden shift.
for _ in 0..100 {
ph.update(5.0).unwrap();
}
assert!(ph.detected());Implementations§
Source§impl PageHinkley
impl PageHinkley
Sourcepub fn new(config: PageHinkleyConfig) -> Result<Self, RillError>
pub fn new(config: PageHinkleyConfig) -> Result<Self, RillError>
Create a new Page-Hinkley detector with the given configuration.
Returns an error if:
thresholdis not finite or not strictly positive.warning_thresholdis negative or greater thanthreshold.alphais not in(0, 1].deltais not finite or is negative.min_samplesis zero.
Sourcepub const fn ph_statistic(&self) -> f64
pub const fn ph_statistic(&self) -> f64
The current test statistic PH_t = S_t − min(S).
Sourcepub const fn config(&self) -> &PageHinkleyConfig
pub const fn config(&self) -> &PageHinkleyConfig
The configuration of this detector.
Sourcepub fn export_state_v1(&self) -> PageHinkleyPortableStateV1
pub fn export_state_v1(&self) -> PageHinkleyPortableStateV1
Export the stable portable state without exposing the detector’s Preview internal serde layout.
Sourcepub fn restore_state_v1(
config: PageHinkleyConfig,
state: PageHinkleyPortableStateV1,
) -> Result<Self, RillError>
pub fn restore_state_v1( config: PageHinkleyConfig, state: PageHinkleyPortableStateV1, ) -> Result<Self, RillError>
Restore from a validated portable state.
The supplied configuration must exactly match the configuration stored in the state, preventing accidental continuation under new semantics.
Trait Implementations§
Source§impl Clone for PageHinkley
impl Clone for PageHinkley
Source§fn clone(&self) -> PageHinkley
fn clone(&self) -> PageHinkley
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PageHinkley
impl Debug for PageHinkley
Source§impl Default for PageHinkley
impl Default for PageHinkley
Source§impl DriftDetector for PageHinkley
impl DriftDetector for PageHinkley
Source§fn update(&mut self, value: f64) -> Result<DriftLevel, RillError>
fn update(&mut self, value: f64) -> Result<DriftLevel, RillError>
Update the detector with a new scalar observation. Read more
Source§fn level(&self) -> DriftLevel
fn level(&self) -> DriftLevel
The current drift level.
Source§fn samples_seen(&self) -> u64
fn samples_seen(&self) -> u64
Number of observations incorporated so far.
Source§fn last_value(&self) -> f64
fn last_value(&self) -> f64
The detector-specific statistic value from the last update. Read more
Auto Trait Implementations§
impl Freeze for PageHinkley
impl RefUnwindSafe for PageHinkley
impl Send for PageHinkley
impl Sync for PageHinkley
impl Unpin for PageHinkley
impl UnsafeUnpin for PageHinkley
impl UnwindSafe for PageHinkley
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