KSWIN#

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

KSWIN (Kolmogorov-Smirnov Windowing) [raab2020reactive] detector.

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

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

References:

[raab2020reactive]

Raab, Christoph, Moritz Heusinger, and Frank-Michael Schleif. “Reactive soft prototype computing for concept drift streams.” Neurocomputing 416 (2020): 340-351.

Example:

>>> from frouros.detectors.concept_drift import KSWIN, KSWINConfig
>>> 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 = KSWIN(config=KSWINConfig(seed=31))
>>> 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 1016
config_type#

alias of KSWINConfig

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 window: deque#

Window queue property.

Returns:

window queue

Return type:

deque

reset() None#

Reset method.