Metadata-Version: 2.4
Name: pybocd
Version: 1.1.0
Project-URL: Documentation, https://github.com/Zeyu-Xie/pybocd#readme
Project-URL: Issues, https://github.com/Zeyu-Xie/pybocd/issues
Project-URL: Source, https://github.com/Zeyu-Xie/pybocd
Author-email: Zeyu Xie <xie.zeyu20@gmail.com>
License: GPL-3.0-or-later
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# pybocd

[![PyPI - Version](https://img.shields.io/pypi/v/pybocd.svg)](https://pypi.org/project/pybocd)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pybocd.svg)](https://pypi.org/project/pybocd)

---

pybocd implements Bayesian Online Changepoint Detection (BOCD) with two built-in observation models:

- BOCD-NIG: conjugate Normal–Inverse–Gamma model for unknown mean and variance.
- BOCD-GMM: particle-based Gaussian mixture model for multimodal data and outliers.

## Installation

```bash
pip install pybocd
```

If you install from source for development, ensure `numpy`, `scipy`, and `pandas` are available.

## Quickstart — BOCD-NIG

```python
from pybocd import BOCDNIG

# prior: m0, kappa0, alpha0, beta0; l: expected run length; threshold: pruning
model = BOCDNIG(m_0=0.0, kappa_0=1.0, alpha_0=1.0, beta_0=1.0, l=200.0, threshold=1e-4)

for x in stream_of_floats:
	model.add_data(x)
	# model.run_length_dist and model.run_length show current posterior

```

## Quickstart — BOCD-GMM

```python
from pybocd import BOCDGMM

# The GMM-based BOCD requires several hyperparameters — see source for details.
model = BOCDGMM(alpha_0=2.0, beta_0=2.0, m_0=0.0, kappa_0=1.0,
				alpha_p_0=2.0, beta_p_0=2.0, mu_p_0=0.0, sigma_p_sq_0=1.0,
				jitter_mu=0.01, jitter_sigma_sq=0.01, jitter_tau_sq=0.01, jitter_pi=0.01,
				l=200.0, m=20, n=200, init_particle_n=50)

for x in stream_of_floats:
	model.add_data(x)

```

## Documentation & Links

- Documentation: https://zeyu-xie.github.io/pybocd/
- PyPI: https://pypi.org/project/pybocd/
- Examples repository: https://github.com/Zeyu-Xie/pybocd-Examples

## Data Attributes

During development, data sourced from [Westermo](https://github.com/westermo/test-system-performance-dataset) is used, which is licensed under the [Creative Commons Attribution 4.0 International (CC BY 4.0)](https://github.com/westermo/test-system-performance-dataset/blob/main/LICENSE) License. We gratefully acknowledge Westermo for making this real-world telemetry data available for research and development purposes.

## License

pybocd is distributed under the terms of the [GPL-3.0-or-later](./LICENSE) license.
