Skip to content


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

HDDM_A is a drift detection method based on the Hoeffding's inequality which uses the input average 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 \neq y'\)

Implementation based on MOA.


  • drift_confidence

    Default → 0.001

    Confidence to the drift

  • warning_confidence

    Default → 0.005

    Confidence to the warning

  • two_sided_test

    Default → False

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


  • 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.


import random
from river import drift

rng = random.Random(42)
hddm_a = drift.binary.HDDM_A()

data_stream = rng.choices([0, 1], k=1000)
data_stream = data_stream + rng.choices([0, 1], k=1000, weights=[0.3, 0.7])

print_warning = True
for i, x in enumerate(data_stream):
    _ = hddm_a.update(x)
    if hddm_a.warning_detected and print_warning:
        print(f"Warning detected at index {i}")
        print_warning = False
    if hddm_a.drift_detected:
        print(f"Change detected at index {i}")
        print_warning = True
Warning detected at index 451
Change detected at index 1206



Update the change detector with a single data point.


  • x — 'bool'


BinaryDriftDetector: self

  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.