ADWIN#

class frouros.detectors.concept_drift.streaming.window_based.ADWIN(config: ADWINConfig | None = None, callbacks: BaseCallbackStreaming | list[BaseCallbackStreaming] | None = None)#

ADWIN (ADaptive WINdowing) [bifet2007learning] detector.

Parameters:
  • config (Optional[ADWINConfig]) – configuration object of the detector, defaults to None. If None, the default configuration of ADWINConfig is used.

  • callbacks (Optional[Union[BaseCallbackStreaming, list[BaseCallbackStreaming]]]) – callbacks, defaults to None

References:

[bifet2007learning]

Bifet, Albert, and Ricard Gavalda. “Learning from time-changing data with adaptive windowing.” Proceedings of the 2007 SIAM international conference on data mining. Society for Industrial and Applied Mathematics, 2007.

Example:

>>> from frouros.detectors.concept_drift import ADWIN
>>> import numpy as np
>>> np.random.seed(seed=31)
>>> dist_a = np.random.normal(loc=0.2, scale=0.01, size=1000)
>>> dist_b = np.random.normal(loc=0.8, scale=0.04, size=1000)
>>> stream = np.concatenate((dist_a, dist_b))
>>> detector = ADWIN()
>>> for i, value in enumerate(stream):
...     _ = detector.update(value=value)
...     if detector.drift:
...         print(f"Change detected at step {i}")
...         break
Change detected at step 1055
config_type#

alias of ADWINConfig

property additional_vars: dict[str, Any] | None#

Additional variables property.

Returns:

additional variables

Return type:

Optional[dict[str, Any]]

property callbacks: list[BaseCallback] | None#

Callbacks property.

Returns:

callbacks

Return type:

Optional[list[BaseCallback]]

property config: BaseConceptDriftConfig#

Config property.

Returns:

configuration parameters of the estimator

Return type:

BaseConceptDriftConfig

property num_instances: int#

Number of instances counter property.

Returns:

Number of instances counter value

Return type:

int

property status: dict[str, bool]#

Status property.

Returns:

status dict

Return type:

dict[str, bool]

update(value: int | float, **kwargs: Any) dict[str, Any]#

Update method.

Parameters:
  • value (Union[int, float]) – value to update detector

  • kwargs (Any) – additional keyword arguments

Returns:

callbacks logs

Return type:

dict[str, Any]]

property buckets: deque#

Buckets queue property.

Returns:

buckets queue

Return type:

deque

property total: float#

Total value property.

Returns:

total value

Return type:

float

property variance: float#

Variance value property.

Returns:

variance value

Return type:

float

property variance_window: float#

Variance in window value property.

Returns:

variance in window value

Return type:

float

property width: int#

Width value property.

Returns:

width value

Return type:

int

property num_buckets: int#

Number of buckets property.

Returns:

number of buckets

Return type:

int

property num_max_buckets: int#

Maximum number of buckets property.

Returns:

maximum number of buckets

Return type:

int

reset() None#

Reset method.