1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Drift detection and adaptation.
//!
//! This module provides bounded-memory drift detection algorithms, a decoupled
//! action/strategy layer, decay-aware learning utilities, and a
//! [`DriftAwareModel`] wrapper that integrates drift detection into the
//! predict → learn loop.
//!
//! ## Overview
//!
//! - **Detectors**: [`PageHinkley`], [`Adwin`], [`Kswin`] — each implements
//! the [`DriftDetector`] trait and reports a [`DriftLevel`]
//! (None / Warning / Drift).
//! - **Actions**: [`DriftAction`] describes what to do when drift is detected.
//! [`DriftStrategy`] maps a level to an action, keeping detection and
//! response decoupled.
//! - **Decay learning**: [`TimeDecayedMean`], [`LearningRateScheduler`],
//! [`FixedWindowBuffer`] — utilities for adapting to non-stationary streams.
//! - **Wrapper**: [`DriftAwareModel`] wraps a model + detector + strategy and
//! automatically responds to drift during `learn`. It does **not**
//! auto-reset the model by default.
//!
//! ## Quick start
//!
//! ```rust
//! use rill_ml::drift::{DriftAction, DriftLevel, PageHinkley, StaticStrategy};
//! use rill_ml::drift::{DriftDetector, DriftStrategy};
//!
//! let mut detector = PageHinkley::default();
//! let strategy = StaticStrategy::new(
//! DriftAction::ReduceConfidence,
//! DriftAction::ResetModel,
//! );
//!
//! // Feed a stable stream.
//! for _ in 0..100 {
//! detector.update(0.0).unwrap();
//! }
//! assert_eq!(detector.level(), DriftLevel::None);
//!
//! // Introduce a sudden shift.
//! for _ in 0..50 {
//! detector.update(5.0).unwrap();
//! }
//! assert!(detector.detected());
//! let action = strategy.decide(detector.level(), detector.samples_seen());
//! assert_eq!(action, DriftAction::ResetModel);
//! ```
//!
//! [`DriftAwareModel`]: crate::drift::aware_model::DriftAwareModel
//! [`PageHinkley`]: crate::drift::page_hinkley::PageHinkley
//! [`Adwin`]: crate::drift::adwin::Adwin
//! [`Kswin`]: crate::drift::kswin::Kswin
//! [`TimeDecayedMean`]: crate::drift::decay::TimeDecayedMean
//! [`LearningRateScheduler`]: crate::drift::decay::LearningRateScheduler
//! [`FixedWindowBuffer`]: crate::drift::decay::FixedWindowBuffer
pub use ;
pub use ;
pub use DriftAwareModel;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;