ADWINΒΆ
Adaptive Windowing method for concept drift detection.
ADWIN (ADaptive WINdowing) is a popular drift detection method with mathematical guarantees. ADWIN efficiently keeps a variable-length window of recent items; such that it holds that there has no been change in the data distribution. This window is further divided into two sub-windows
ParametersΒΆ
-
delta β defaults to
0.002
Significance value.
AttributesΒΆ
-
drift_detected
Concept drift alarm. True if concept drift is detected.
-
estimation
Estimate of mean value in the window.
-
n_detections
-
total
-
variance
-
width
Window size
ExamplesΒΆ
>>> import random
>>> from river import drift
>>> rng = random.Random(12345)
>>> adwin = drift.ADWIN()
>>> # Simulate a data stream composed by two data distributions
>>> data_stream = rng.choices([0, 1], k=1000) + rng.choices(range(4, 8), k=1000)
>>> # Update drift detector and verify if change is detected
>>> for i, val in enumerate(data_stream):
... _ = adwin.update(val)
... if adwin.drift_detected:
... print(f"Change detected at index {i}, input value: {val}")
Change detected at index 1023, input value: 4
MethodsΒΆ
update
Update the change detector with a single data point.
Apart from adding the element value to the window, by inserting it in the correct bucket, it will also update the relevant statistics, in this case the total sum of all values, the window width and the total variance.
Parameters
- x (numbers.Number)
Returns
DriftDetector: self
ReferencesΒΆ
-
Albert Bifet and Ricard Gavalda. "Learning from time-changing data with adaptive windowing." In Proceedings of the 2007 SIAM international conference on data mining, pp. 443-448. Society for Industrial and Applied Mathematics, 2007. β©