KSWINΒΆ
Kolmogorov-Smirnov Windowing method for concept drift detection.
ParametersΒΆ
-
alpha (float) β defaults to
0.005
Probability for the test statistic of the Kolmogorov-Smirnov-Test. The alpha parameter is very sensitive, therefore should be set below 0.01.
-
window_size (int) β defaults to
100
Size of the sliding window.
-
stat_size (int) β defaults to
30
Size of the statistic window.
-
seed (int) β defaults to
None
Random seed for reproducibility.
-
window (Iterable) β defaults to
None
Already collected data to avoid cold start.
AttributesΒΆ
-
drift_detected
Concept drift alarm. True if concept drift is detected.
ExamplesΒΆ
>>> import random
>>> from river import drift
>>> rng = random.Random(12345)
>>> kswin = drift.KSWIN(alpha=0.0001, seed=42)
>>> # 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):
... _ = kswin.update(val)
... if kswin.drift_detected:
... print(f"Change detected at index {i}, input value: {val}")
Change detected at index 1016, input value: 6
MethodsΒΆ
update
Update the change detector with a single data point.
Adds an element on top of the sliding window and removes the oldest one from the window. Afterwards, the KS-test is performed.
Parameters
- x (numbers.Number)
Returns
DriftDetector: self
NotesΒΆ
KSWIN (Kolmogorov-Smirnov Windowing) is a concept change detection method based on the Kolmogorov-Smirnov (KS) statistical test. KS-test is a statistical test with no assumption of underlying data distribution. KSWIN can monitor data or performance distributions. Note that the detector accepts one dimensional input as array.
KSWIN maintains a sliding window
The KS-test is performed on the windows
A concept drift is detected by KSWIN if:
The difference in empirical data distributions between the windows
ReferencesΒΆ
-
Christoph Raab, Moritz Heusinger, Frank-Michael Schleif, Reactive Soft Prototype Computing for Concept Drift Streams, Neurocomputing, 2020, β©