https://github.com/deepcharles/circruptures
https://github.com/deepcharles/circruptures
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deepcharles/circruptures
- Owner: deepcharles
- License: mit
- Created: 2024-11-05T21:00:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-19T13:04:58.000Z (about 1 year ago)
- Last Synced: 2025-06-19T14:22:30.571Z (about 1 year ago)
- Language: Jupyter Notebook
- Size: 1.11 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Change point detection for circular time series
## Install
```bash
python -m pip install .
```
## Example
```Python
import matplotlib.pyplot as plt
import numpy as np
from circruptures import (
get_bkps,
estimate_var,
distance_between_bkps,
convert_bkps_to_distrib,
get_approx,
)
# Assume data are in a variable named `signal`
# compute change points
penalty_factor = 14_000
n_samples = signal.shape[0]
variance = estimate_var(signal, n_segments=50)
bkps = get_bkps(
signal,
penalty=penalty_factor * np.log(n_samples) * variance,
return_approx=False,
n_states=20,
)
# Plot signal and its approximation
approx = get_approx(signal, bkps)
for dim in range(2):
fig, ax = plt.subplots(figsize=(10, 3))
ax.plot(signal[:, dim])
ax.plot(approx[:, dim])
ax.set_xmargin(0)
_ = ax.set_ylim(-np.pi, np.pi)
```