STEPD#

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

STEPD (Statistical test of equal proportions) [nishida2007detecting] detector.

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

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

References:

[nishida2007detecting]

Nishida, Kyosuke, and Koichiro Yamauchi. “Detecting concept drift using statistical testing.” Discovery science. Vol. 4755. 2007.

Example:

>>> from frouros.detectors.concept_drift import STEPD, STEPDConfig
>>> import numpy as np
>>> np.random.seed(seed=31)
>>> dist_a = np.random.binomial(n=1, p=0.8, size=1000)
>>> dist_b = np.random.binomial(n=1, p=0.5, size=1000)
>>> stream = np.concatenate((dist_a, dist_b))
>>> detector = STEPD(config=STEPDConfig(alpha_d=0.001, alpha_w=0.005))
>>> for i, value in enumerate(stream):
...     _ = detector.update(value=value)
...     if detector.drift:
...         print(f"Change detected at step {i}")
...         break
...     if detector.warning:
...         print(f"Warning detected at step {i}")
Warning detected at step 640
Warning detected at step 641
Warning detected at step 1023
Change detected at step 1024
config_type#

alias of STEPDConfig

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

Additional variables property.

Returns:

additional variables

Return type:

Optional[dict[str, Any]]

property warning: bool#

Warning property.

Returns:

warning

Return type:

bool

property correct_total: int#

Number of correct labels property.

Returns:

accuracy scorer function

Return type:

int

property num_instances_overall: int#

Number of overall instances property.

Returns:

number of overall instances

Return type:

int

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 correct_overall: int#

Number of correct overall labels property.

Returns:

number of overall labels

Return type:

int

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 correct_window: int#

Number of correct window labels property.

Returns:

number of window labels

Return type:

int

property num_instances_window: int#

Number of window instances property.

Returns:

number of window instances

Return type:

int

property window_accuracy: AccuracyQueue#

Accuracy window property.

Returns:

accuracy window

Return type:

AccuracyQueue

reset() None#

Reset method.