abstract_bayesian
Abstract Bayesian base implementation.
- class pysatl_cpd.algorithms.online.bayesian.algorithm.abstract_bayesian.BayesianOnlineCPDConfiguration(*, learning_period_size=0, window=None, cpf_type=BayesianCPFType.MAX_RUN_LENGTH)[source]
Bases:
OnlineAlgorithmConfigurationBase configuration for Bayesian online CPD algorithms.
- cpf_type: BayesianCPFType = 'max_run_length'
- __post_init__()[source]
Validate configuration fields after initialisation.
- Raises:
ValueError – If learning_period_size is negative, or window is non-positive when provided.
- Return type:
- class pysatl_cpd.algorithms.online.bayesian.algorithm.abstract_bayesian.BayesianOnlineCPDState(*, is_in_learning_period=False, t=0, run_length_log_posterior=<factory>)[source]
Bases:
OnlineAlgorithmStateBase state for Bayesian online CPD algorithms.
- Variables:
t – Current time step.
run_length_log_posterior – Log-posterior distribution over run lengths.
- Parameters:
- class pysatl_cpd.algorithms.online.bayesian.algorithm.abstract_bayesian.AbstractBayesian(configuration, hazard, likelihood, cpf)[source]
Bases:
OnlineAlgorithm[float,BayesianOnlineCPDConfiguration,BayesianOnlineCPDState],ABCBase class for configurable online Bayesian detectors.
Implements the Bayesian online change-point detection (BOCPD) message-passing loop. Subclasses must provide the name property and wire up the concrete hazard, likelihood, and cpf components.
- Parameters:
configuration (
BayesianOnlineCPDConfiguration) – Algorithm configuration.hazard (
IHazard) – Hazard function defining the prior over run lengths.likelihood (
ILikelihood) – Predictive likelihood model.cpf (
IBayesianCPF) – Change-point score function.
- __init__(configuration, hazard, likelihood, cpf)[source]
- Parameters:
configuration (BayesianOnlineCPDConfiguration)
hazard (IHazard)
likelihood (ILikelihood)
cpf (IBayesianCPF)
- Return type:
None
- property configuration: BayesianOnlineCPDConfiguration
Return the current algorithm configuration.
- Return type:
- property state: BayesianOnlineCPDState
Materialise an immutable snapshot of the current state.
- Return type:
- process(observation)[source]
Ingest one observation and return the change-point score.
- Implements the BOCPD message-passing update:
Predictive probabilities from the likelihood model.
Hazard-based growth / change-point probabilities.
Normalise and optionally truncate to window.
Return CPF score (or 0 during learning period).