Expand description
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 theDriftDetectortrait and reports aDriftLevel(None / Warning / Drift). - Actions:
DriftActiondescribes what to do when drift is detected.DriftStrategymaps a level to an action, keeping detection and response decoupled. - Decay learning:
TimeDecayedMean,LearningRateScheduler,FixedWindowBuffer— utilities for adapting to non-stationary streams. - Wrapper:
DriftAwareModelwraps a model + detector + strategy and automatically responds to drift duringlearn. It does not auto-reset the model by default.
§Quick start
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);Re-exports§
pub use action::DriftAction;pub use action::DriftEvent;pub use adwin::Adwin;pub use adwin::AdwinConfig;pub use aware_model::DriftAwareModel;pub use decay::FixedWindowBuffer;pub use decay::LearningRateScheduler;pub use decay::TimeDecayedMean;pub use detector::DriftDetector;pub use detector::DriftLevel;pub use kswin::Kswin;pub use kswin::KswinConfig;pub use page_hinkley::PageHinkley;pub use page_hinkley::PageHinkleyConfig;pub use strategy::DriftStrategy;pub use strategy::StaticStrategy;
Modules§
- action
- Drift action and event types.
- adwin
- ADWIN (Adaptive Windowing) drift detector.
- aware_
model - A model wrapper that integrates drift detection into the predict → learn loop.
- decay
- Decay-aware learning utilities.
- detector
- Core drift detector trait.
- kswin
- KSWIN (Kolmogorov-Smirnov Windowing) drift detector.
- page_
hinkley - Page-Hinkley sequential change detection.
- strategy
- Drift handling strategies.