# skmultiflow.drift_detection.HDDM_W¶

class skmultiflow.drift_detection.HDDM_W(drift_confidence=0.001, warning_confidence=0.005, lambda_option=0.05, two_side_option=True)[source]

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

Parameters
drift_confidencefloat (default=0.001)

Confidence to the drift

warning_confidencefloat (default=0.005)

Confidence to the warning

lambda_optionfloat (default=0.050)

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

two_side_optionbool (default=True)

Option to monitor error increments and decrements (two-sided) or only increments (one-sided)

Notes

HDDM_W [1] is an online drift detection method based on McDiarmid’s bounds. HDDM_W uses the EWMA statistic as estimator. It receives as input a stream of real predictions and returns the estimated status of the stream: STABLE, WARNING or DRIFT.

Implementation based on MOA [2].

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.

Examples

>>> # Imports
>>> import numpy as np
>>> from skmultiflow.drift_detection.hddm_w import HDDM_W
>>> hddm_w = HDDM_W()
>>> # 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 1500, simulating an
>>> # increase in error rate
>>> for i in range(999, 1500):
...     data_stream[i] = 0
>>> # Adding stream elements to HDDM_A and verifying if drift occurred
>>> for i in range(2000):
...     if hddm_w.detected_warning_zone():
...         print('Warning zone has been detected in data: ' + str(data_stream[i]) + ' - of index: ' + str(i))
...     if hddm_w.detected_change():
...         print('Change has been detected in data: ' + str(data_stream[i]) + ' - of index: ' + str(i))


Methods

 add_element(self, prediction) Add a new element to the statistics This function returns whether concept drift was detected or not. If the change detector supports the warning zone, this function will return whether it’s inside the warning zone or not. get_info(self) Collects and returns the information about the configuration of the estimator Returns the length estimation. get_params(self[, deep]) Get parameters for this estimator. reset(self) Resets the change detector parameters. set_params(self, **params) Set the parameters of this estimator.

Attributes

 estimator_type
add_element(self, prediction)[source]

Add a new element to the statistics

Parameters
prediction: int (either 0 or 1)

This parameter indicates whether the last sample analyzed was correctly classified or not. 1 indicates an error (miss-classification).

Notes

After calling self method, to verify if change was detected or if the learner is in the warning zone, one should call the super method detected_change, which returns True if concept drift was detected and False otherwise.

detected_change(self)[source]

This function returns whether concept drift was detected or not.

Returns
bool

Whether concept drift was detected or not.

detected_warning_zone(self)[source]

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

Returns
bool

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

get_info(self)[source]

Collects and returns the information about the configuration of the estimator

Returns
string

Configuration of the estimator.

get_length_estimation(self)[source]

Returns the length estimation.

Returns
int

The length estimation

get_params(self, deep=True)[source]

Get parameters for this estimator.

Parameters
deepboolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsmapping of string to any

Parameter names mapped to their values.

reset(self)[source]

Resets the change detector parameters.

set_params(self, **params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns
self