utils

Factory helpers for Bayesian online change-point detection components.

This module provides factory functions that construct the three core building blocks of a Bayesian online change-point detection system: hazard functions, likelihood models, and change-point score functions (CPF). Each factory returns an object conforming to the corresponding protocol defined in the sibling protocol subpackage.

The concrete implementations live in the component subpackage. Use these factories to obtain correctly configured instances without importing the implementation classes directly.

Public API

  • get_hazard_function(lambda_) -> IHazard Builds a constant hazard model with the given expected run length.

  • get_likelihood_function(mu_0, k_0, alpha_0, beta_0) -> ILikelihood Builds a Gaussian conjugate likelihood with the specified prior parameters.

  • get_cpf_function(cpf_type) -> IBayesianCPF Builds a change-point score function selected by BayesianCPFType.

Notes

The BayesianCPFType enum is defined in pysatl_cpd.algorithms.online.bayesian._enum and re-exported from the parent bayesian package.

Examples

Construct all three components for a univariate Gaussian BOCPD setup:

>>> from pysatl_cpd.algorithms.online import BayesianCPFType
>>> from pysatl_cpd.algorithms.online.bayesian.utils import (
...     get_cpf_function,
...     get_hazard_function,
...     get_likelihood_function,
... )
>>> hazard = get_hazard_function(lambda_=10.0)
>>> likelihood = get_likelihood_function(mu_0=0.0, k_0=1.0, alpha_0=1.0, beta_0=1.0)
>>> cpf = get_cpf_function(BayesianCPFType.MAX_RUN_LENGTH)