Skip to content

PageHinkley

Page-Hinkley method for concept drift detection.

This change detection method works by computing the observed values and their mean up to the current moment. Page-Hinkley does not signal warning zones, only change detections.

This detector implements the CUSUM control chart for detecting changes. This implementation also supports the two-sided Page-Hinkley test to detect increasing and decreasing changes in the mean of the input values.

Parameters

  • min_instances (int) – defaults to 30

    The minimum number of instances before detecting change.

  • delta (float) – defaults to 0.005

    The delta factor for the Page-Hinkley test.

  • threshold (float) – defaults to 50.0

    The change detection threshold (lambda).

  • alpha (float) – defaults to 0.9999

    The forgetting factor, used to weight the observed value and the mean.

  • mode (str) – defaults to both

    Whether to consider increases ("up"), decreases ("down") or both ("both") when monitoring the fading mean.

Attributes

  • drift_detected

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

Examples

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

>>> rng = random.Random(12345)
>>> ph = drift.PageHinkley()

>>> # 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):
...     _ = ph.update(val)
...     if ph.drift_detected:
...         print(f"Change detected at index {i}, input value: {val}")
Change detected at index 1006, input value: 5

Methods

update

Update the detector with a single data point.

Parameters

  • x (numbers.Number)

Returns

DriftDetector: self

References


  1. E. S. Page. 1954. Continuous Inspection Schemes. Biometrika 41, 1/2 (1954), 100-115. 

  2. SebastiΓ£o, R., & Fernandes, J. M. (2017, June). Supporting the Page-Hinkley test with empirical mode decomposition for change detection. In International Symposium on Methodologies for Intelligent Systems (pp. 492-498). Springer, Cham.