IncrementalKSTest#

class frouros.detectors.data_drift.streaming.statistical_test.IncrementalKSTest(window_size: int, callbacks: Optional[Union[BaseCallbackStreaming, List[BaseCallbackStreaming]]] = None)#

IncrementalKSTest (Incremental Kolmogorov-Smirnov test) [dos2016fast] detector.

Parameters:
  • window_size (int) – window size value

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

References:

[dos2016fast]

dos Reis, Denis Moreira, et al. “Fast unsupervised online drift detection using incremental kolmogorov-smirnov test.” Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data mining. 2016.

Example:

>>> from frouros.detectors.data_drift import IncrementalKSTest
>>> import numpy as np
>>> np.random.seed(seed=31)
>>> X = np.random.normal(loc=0, scale=1, size=100)
>>> Y = np.random.normal(loc=1, scale=1, size=100)
>>> detector = IncrementalKSTest(window_size=10)
>>> _ = detector.fit(X=X)
>>> for sample in Y:
...     test, _ = detector.update(value=sample)
...     if test is not None:
...         print(test.statistic, test.p_value)
property window_size: int#

Window size property.

Returns:

window size

Return type:

int

property X_ref: Optional[ndarray]#

Reference data property.

Returns:

reference data

Return type:

Optional[numpy.ndarray]

property callbacks: Optional[List[BaseCallback]]#

Callbacks property.

Returns:

callbacks

Return type:

Optional[List[BaseCallback]]

property data_type: BaseDataType#

Data type property.

Returns:

data type

Return type:

BaseDataType

fit(X: ndarray, **kwargs) Dict[str, Any]#

Fit detector.

Parameters:

X (numpy.ndarray) – feature data

Returns:

callbacks logs

Return type:

Dict[str, Any]

reset() None#

Reset method.

property statistical_type: BaseStatisticalType#

Statistical type property.

Returns:

statistical type

Return type:

BaseStatisticalType

update(value: Union[int, float]) Tuple[Optional[BaseResult], Dict[str, Any]]#

Update detector.

Parameters:

value (Union[int, float]) – value to use to update the detector

Returns:

update result and callbacks logs

Return type:

Tuple[Optional[BaseResult], Dict[str, Any]]