Skip to content

HDDM_Wยถ

Drift Detection Method based on Hoeffding's bounds with moving weighted average-test.

HDDM_W is an online drift detection method based on McDiarmid's bounds. HDDM_W uses the Exponentially Weighted Moving Average (EWMA) statistic as estimator.

Input: x is an entry in a stream of bits, where 1 indicates error/failure and 0 represents correct/normal values.

For example, if a classifier's prediction yโ€ฒ is right or wrong w.r.t. the true target label y:

  • 0: Correct, y=yโ€ฒ

  • 1: Error, yโ‰ yโ€ฒ

Implementation based on MOA.

Parametersยถ

  • drift_confidence โ€“ defaults to 0.001

    Confidence to the drift

  • warning_confidence โ€“ defaults to 0.005

    Confidence to the warning

  • lambda_val โ€“ defaults to 0.05

    The weight given to recent data. Smaller values mean less weight given to recent data.

  • two_sided_test โ€“ defaults to False

    If True, will monitor error increments and decrements (two-sided). By default will only monitor increments (one-sided).

Attributesยถ

  • drift_detected

    Whether or not a drift is detected following the last update.

  • warning_detected

    Whether or not a drift is detected following the last update.

Examplesยถ

>>> import random
>>> from river import drift

>>> rng = random.Random(42)
>>> hddm_w = drift.binary.HDDM_W()

>>> # Simulate a data stream where the first 1000 instances come from a uniform distribution
>>> # of 1's and 0's
>>> data_stream = rng.choices([0, 1], k=1000)
>>> # Increase the probability of 1's appearing in the next 1000 instances
>>> data_stream = data_stream + rng.choices([0, 1], k=1000, weights=[0.3, 0.7])

>>> print_warning = True
>>> # Update drift detector and verify if change is detected
>>> for i, x in enumerate(data_stream):
...     _ = hddm_w.update(x)
...     if hddm_w.warning_detected and print_warning:
...         print(f"Warning detected at index {i}")
...         print_warning = False
...     if hddm_w.drift_detected:
...         print(f"Change detected at index {i}")
...         print_warning = True
Warning detected at index 451
Change detected at index 1077

Methodsยถ

update

Update the change detector with a single data point.

Parameters

  • x (bool)

Returns

BinaryDriftDetector: self

Referencesยถ


  1. Frรญas-Blanco I, del Campo-รvila J, Ramos-Jimenez G, et al. Online and non-parametric drift detection methods based on Hoeffdingโ€™s bounds. IEEE Transactions on Knowledge and Data Engineering, 2014, 27(3): 810-823. โ†ฉ

  2. Albert Bifet, Geoff Holmes, Richard Kirkby, Bernhard Pfahringer. MOA: Massive Online Analysis; Journal of Machine Learning Research 11: 1601-1604, 2010. โ†ฉ