Skip to main content

A Bayesian change point library

Project description

changepoint

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

Installation

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 https://sh.rustup.rs | sh
python3 -m pip install maturin

See rustup.rs for instructions on installing Rust.

Quick Docs

By convention in these docs and examples,

import changepoint as cpt

Models

Bocpd

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

cpt.BetaBernoulli
cpt.NormalGamma
cpt.NormalInvChiSquared
cpt.NormalInvGamma
cpt.NormalInvWishart
cpt.PoissonGamma

Then, a Bocpd may be created:

cpd = cpt.Bocpd(
    prior=cpt.NormalGamma(),
    lam=12,
)

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)

print(cpt.map_changepoints(change_point_history))

ArgpCpd

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

print(cpt.map_changepoints(change_point_history))

Example

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.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (476.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (492.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

changepoint-0.3.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (475.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (546.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

changepoint-0.3.2-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (537.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (465.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (475.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (492.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

changepoint-0.3.2-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (548.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

changepoint-0.3.2-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (538.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (465.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (474.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-pp37-pypy37_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (550.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

changepoint-0.3.2-pp37-pypy37_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (541.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-pp37-pypy37_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (467.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp312-none-win_amd64.whl (305.5 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

changepoint-0.3.2-cp312-none-win32.whl (286.3 kB view hashes)

Uploaded CPython 3.12 Windows x86

changepoint-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (532.5 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

changepoint-0.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (536.8 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (471.8 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (491.7 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

changepoint-0.3.2-cp312-cp312-macosx_11_0_arm64.whl (409.9 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

changepoint-0.3.2-cp312-cp312-macosx_10_12_x86_64.whl (421.5 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

changepoint-0.3.2-cp311-none-win_amd64.whl (305.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

changepoint-0.3.2-cp311-none-win32.whl (287.0 kB view hashes)

Uploaded CPython 3.11 Windows x86

changepoint-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (473.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (546.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

changepoint-0.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (538.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (465.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (473.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (492.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

changepoint-0.3.2-cp311-cp311-macosx_11_0_arm64.whl (409.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

changepoint-0.3.2-cp311-cp311-macosx_10_12_x86_64.whl (421.9 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

changepoint-0.3.2-cp310-none-win_amd64.whl (305.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

changepoint-0.3.2-cp310-none-win32.whl (287.0 kB view hashes)

Uploaded CPython 3.10 Windows x86

changepoint-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (473.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (546.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

changepoint-0.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (538.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (465.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (473.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (492.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

changepoint-0.3.2-cp310-cp310-macosx_11_0_arm64.whl (409.6 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

changepoint-0.3.2-cp310-cp310-macosx_10_12_x86_64.whl (421.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

changepoint-0.3.2-cp39-none-win_amd64.whl (305.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

changepoint-0.3.2-cp39-none-win32.whl (287.3 kB view hashes)

Uploaded CPython 3.9 Windows x86

changepoint-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (546.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

changepoint-0.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (538.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (465.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (473.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (492.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

changepoint-0.3.2-cp39-cp39-macosx_11_0_arm64.whl (409.8 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

changepoint-0.3.2-cp39-cp39-macosx_10_12_x86_64.whl (422.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ x86-64

changepoint-0.3.2-cp38-none-win_amd64.whl (305.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

changepoint-0.3.2-cp38-none-win32.whl (286.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

changepoint-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (474.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (546.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

changepoint-0.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (537.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (464.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (473.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (492.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

changepoint-0.3.2-cp37-none-win_amd64.whl (305.1 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

changepoint-0.3.2-cp37-none-win32.whl (286.1 kB view hashes)

Uploaded CPython 3.7 Windows x86

changepoint-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (475.9 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

changepoint-0.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl (546.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ s390x

changepoint-0.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (537.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ppc64le

changepoint-0.3.2-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (465.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARMv7l

changepoint-0.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (473.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

changepoint-0.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl (492.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ i686

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