skmultiflow.drift_detection.page_hinkley

Classes

PageHinkley([min_num_instances, delta, …])

Page-Hinkley method for concept drift detection

class skmultiflow.drift_detection.page_hinkley.PageHinkley(min_num_instances=30, delta=0.005, threshold=50, alpha=0.9999)[source][source]

Page-Hinkley method for concept drift detection

Notes

This change detection method works by computing the observed values and their mean up to the current moment. Page-Hinkley won’t output warning zone warnings, only change detections. The method works by means of the Page-Hinkley test [1]. In general lines it will detect a concept drift if the observed mean at some instant is greater then a threshold value lambda.

References

1

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

Parameters
  • min_num_instances (int (default=30)) – The minimum number of instances before detecting change.

  • delta (float (default=0.005)) – The delta factor for the Page Hinkley test.

  • threshold (int (default=50)) – The change detection threshold (lambda).

  • alpha (float (default=1 - 0.0001)) – The forgetting factor, used to weight the observed value and the mean.

Examples

>>> # Imports
>>> import numpy as np
>>> from skmultiflow.drift_detection import PageHinkley
>>> ph = PageHinkley()
>>> # Simulating a data stream as a normal distribution of 1's and 0's
>>> data_stream = np.random.randint(2, size=2000)
>>> # Changing the data concept from index 999 to 2000
>>> for i in range(999, 2000):
...     data_stream[i] = np.random.randint(4, high=8)
>>> # Adding stream elements to the PageHinkley drift detector and verifying if drift occurred
>>> for i in range(2000):
...     ph.add_element(data_stream[i])
...     if ph.detected_change():
...         print('Change has been detected in data: ' + str(data_stream[i]) + ' - of index: ' + str(i))
add_element(x)[source][source]

Add a new element to the statistics

Parameters

x (numeric value) – The observed value, from which we want to detect the concept change.

Notes

After calling this method, to verify if change was detected, one should call the super method detected_change, which returns True if concept drift was detected and False otherwise.

detected_change()[source]

This function returns whether concept drift was detected or not.

Returns

Whether concept drift was detected or not.

Return type

bool

detected_warning_zone()[source]

If the change detector supports the warning zone, this function will return whether it’s inside the warning zone or not.

Returns

Whether the change detector is in the warning zone or not.

Return type

bool

get_class_type()[source]

The class type is a string that identifies the type of object generated by that module.

Returns

Return type

The class type

get_info()[source][source]

Collect information about the concept drift detector.

Returns

Configuration for the concept drift detector.

Return type

string

get_length_estimation()[source]

Returns the length estimation.

Returns

The length estimation

Return type

int

reset()[source][source]

Resets the change detector parameters.