changepy
raw JSON → 0.4.0 verified Fri May 01 auth: no python
Changepoint detection on time series in Python. Version 0.4.0 provides algorithms like PELT and binary segmentation for detecting shifts in mean and variance. Low release cadence; last release in 2020.
pip install changepy Common errors
error ImportError: cannot import name 'pelt' from 'changepy' ↓
cause Outdated or incorrect installation; package may not be installed correctly.
fix
Ensure changepy is installed: pip install --upgrade changepy
error ValueError: The model must be one of 'mean', 'var', or 'meanvar'. ↓
cause Using an invalid model argument in pelt() or binseg().
fix
Use one of the allowed string values: 'mean', 'var', or 'meanvar'.
Warnings
gotcha The PELT implementation expects data to be an array-like of floats. Passing integer arrays may cause type errors. ↓
fix Convert your data to float: arr = np.array(data, dtype=float).
deprecated No active development since 2020; consider using ruptures for maintained changepoint detection. ↓
fix Switch to ruptures (pip install ruptures) for more algorithms and active maintenance.
Imports
- pelt
from changepy import pelt - binseg
from changepy import binseg
Quickstart
import numpy as np
from changepy import pelt
# Generate example time series with one changepoint
np.random.seed(42)
ts = np.concatenate([np.random.normal(0, 1, 50),
np.random.normal(5, 1, 50)])
# Detect changepoints
changepoints = pelt(ts, penalty=2*np.log(len(ts)))
print(changepoints) # Expected: [49] (0-indexed), typically