ADWIN is a drift detection method that maintains a variable-length window of recent data to detect concept drift with mathematical guarantees. Based on the algorithm from Bifet and Gavalda (2007).
Details
The algorithm maintains a sliding window W with the most recent elements. It compares the distribution of two sub-windows (W0 and W1) and detects drift when their means differ significantly according to the Hoeffding bound. Uses bucket compression for memory efficiency.
References
Bifet, A., & Gavalda, R. (2007). Learning from time-changing data with adaptive windowing. In Proceedings of the 2007 SIAM International Conference on Data Mining (pp. 443-448).
Public fields
deltaSignificance threshold for drift detection
clockFrequency of drift checks
max_bucketsMaximum buckets per level
min_window_lengthMinimum window length for comparison
grace_periodInitial period before detection starts
Methods
Method new()
Initialize ADWIN detector
Usage
ADWIN$new(
delta = 0.002,
clock = 32,
max_buckets = 5,
min_window_length = 5,
grace_period = 10
)Examples
set.seed(12345)
adwin <- ADWIN$new()
# Stream: 1000 values from {0,1}, then 1000 values from {4,5,6,7}
stream <- c(sample(0:1, 1000, replace = TRUE),
sample(4:7, 1000, replace = TRUE))
for (i in seq_along(stream)) {
adwin$add_element(stream[i])
if (adwin$detected_change()) {
message("Change detected at index ", i, ", input value: ", stream[i])
}
}
#> Change detected at index 1024, input value: 6
