BOCD#
- class frouros.detectors.concept_drift.streaming.change_detection.BOCD(config: BOCDConfig | None = None, callbacks: BaseCallbackStreaming | list[BaseCallbackStreaming] | None = None)#
BOCD (Bayesian Online Change Detection) [adams2007bayesian] detector.
- Parameters:
config (Optional[BOCDConfig]) – configuration object of the detector, defaults to None. If None, the default configuration of
BOCDConfig
is used.callbacks (Optional[Union[BaseCallbackStreaming, list[BaseCallbackStreaming]]]) – callbacks, defaults to None
- Note:
Adapted from the implementation in gwgundersen/bocd.
- References:
[adams2007bayesian]Adams, Ryan Prescott, and David JC MacKay. “Bayesian online changepoint detection.” arXiv preprint arXiv:0710.3742 (2007).
- Example:
>>> from frouros.detectors.concept_drift import BOCD >>> 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 = BOCD() >>> 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 1031
- config_type#
alias of
BOCDConfig
- property additional_vars: dict[str, Any] | None#
Additional variables property.
- Returns:
additional variables
- Return type:
Optional[dict[str, Any]]
- property log_r: ndarray#
Log r getter.
- Returns:
log r
- Return type:
numpy.ndarray
- 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 predicted_mean: float | None#
Predicted mean getter.
- Returns:
predicted mean
- Return type:
Optional[float]
- property predicted_var: float | None#
Predicted variance getter.
- Returns:
predicted variance
- Return type:
Optional[float]
- property log_message: ndarray#
Log message getter.
- Returns:
log message
- Return type:
numpy.ndarray
- reset() None #
Reset method.