Skip to main content

A Bayesian change point library

Project description


Python bindings for important functionality of the rust library changepoint, a library for doing change point detection for steams of data.


Install via pip with

$ python3 -m pip install "changepoint"

Note: If there is no binary distribution for your OS, architecture, and Python version, you will need the Rust compiler to build the package and install a Python tool called Maturin:

curl --proto '=https' --tlsv1.2 -sSf | sh
python3 -m pip install maturin

See for instructions on installing Rust.

Quick Docs

By convention in these docs and examples,

import changepoint as cpt



The Bayesian change point detector, Bocpd, takes a prior distribution, aka one of


Then, a Bocpd may be created:

cpd = cpt.Bocpd(

where the prior is a NormalGamma and the characteristic run length is 12.

Each step of the data stream, data, can be processed by

import random
import numpy as np

data = [random.gauss() for _ in range(30)] \
    + [random.gauss(1, 2) for _ in range(30)]

n = len(data)
change_point_history = np.zeros((n, n))
for i, x in enumerate(data):
    change_point_history[i, : i + 1] = cpd.step(x)



ArgpCpd has an implicit prior as it is a Gaussian Process of the form X_{i+1} = c X_{i-l-1, ..., i-1} + ε where c is the scale, X_{i-l-1, ..., i-1} is the previous vales in the sequence (l is the max-lag parameter), and ε is a white noise parameter. It behaves similarity to the Bocpd class; for example,

argp = cpt.ArgpCpd(logistic_hazard_h=-2, scale=3, noise_level=0.01)
n = len(data)
change_point_history = np.zeros((n + 1, n + 1))
xs = []
ys = []
for i, x in enumerate(data):
    cps = argp.step(x)
    change_point_history[i, : len(cps)] = cps



An example IPython notebook can be found here.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distributions

changepoint-0.3.1-cp311-none-win_amd64.whl (319.9 kB view hashes)

Uploaded cp311

changepoint-0.3.1-cp311-none-win32.whl (302.8 kB view hashes)

Uploaded cp311

changepoint-0.3.1-cp310-none-win_amd64.whl (319.9 kB view hashes)

Uploaded cp310

changepoint-0.3.1-cp310-none-win32.whl (302.8 kB view hashes)

Uploaded cp310

changepoint-0.3.1-cp39-none-win_amd64.whl (320.2 kB view hashes)

Uploaded cp39

changepoint-0.3.1-cp39-none-win32.whl (303.0 kB view hashes)

Uploaded cp39

changepoint-0.3.1-cp38-none-win_amd64.whl (319.2 kB view hashes)

Uploaded cp38

changepoint-0.3.1-cp38-none-win32.whl (303.1 kB view hashes)

Uploaded cp38

changepoint-0.3.1-cp37-none-win_amd64.whl (319.2 kB view hashes)

Uploaded cp37

changepoint-0.3.1-cp37-none-win32.whl (302.9 kB view hashes)

Uploaded cp37

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page