ADWINDriftDetector<T>
Models & Types · AiDotNet.OnlineLearning
ADWIN (ADaptive WINdowing) drift detector for concept drift detection in data streams.
Implements: IDriftDetector<T>
For Beginners
ADWIN is like a smart sliding window that automatically adjusts its size based on whether the data is stable or changing:
When data is stable:
- Window grows to include more history
- More data = more accurate estimates
When drift occurs:
- Window shrinks to forget old (now irrelevant) data
- Model adapts quickly to new patterns
How it works:
- Maintains a window W of recent values
- For each new value, checks if there’s a “cut point” where:
- W₁ = data before cut, W₂ = data after cut
- If |mean(W₁) - mean(W₂)| > threshold, drift is detected
- When drift detected, discards W₁ (old data)
The threshold is based on the Hoeffding bound, providing statistical guarantees:
- P(false alarm) bounded by δ
- P(missing real drift) bounded by δ
Key advantage: No need to set window size manually - ADWIN adapts!
Usage:
References:
- Bifet & Gavaldà (2007). “Learning from Time-Changing Data with Adaptive Windowing”
How It Works
ADWIN maintains a variable-length window of recent data and automatically shrinks it when a significant change in the mean is detected. It provides theoretical guarantees on false positive/negative rates.
Constructors
| Constructor | Summary |
|---|---|
ADWINDriftDetector(double delta, int maxBucketsPerLevel) |
Initializes a new instance of the ADWINDriftDetector class. |
Properties
| Property | Summary |
|---|---|
bool IsDriftDetected { get; } |
Gets whether drift has been detected. |
bool IsWarning { get; } |
Gets whether a warning has been detected. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetStatistics() |
Gets current detection statistics. |
DriftStatus Update(T value) |
Updates the detector with a new observation. |
T GetWindowMean() |
Gets the current mean of the window. |
T GetWindowVariance() |
Gets the estimation of variance in the window. |
long GetChangePoint() |
Gets the estimated change point. |
long GetWindowSize() |
Gets the current window size. |
void Reset() |
Resets the detector to its initial state. |