skchange
Skchange provides fast and flexible changepoint detection algorithms within a scikit-learn-like API. See the documentation for full details.
Users upgrading from version <0.17 should consult the migration guide.
Installation
It is recommended to install skchange with numba for faster performance:
pip install skchange[numba]
Alternatively, you can install skchange without numba:
pip install skchange
Quickstart
Changepoint detection / time series segmentation
from skchange.datasets import generate_piecewise_normal_data
from skchange.detectors import MovingWindow
X = generate_piecewise_normal_data(
means=[0, 5, 10, 5, 0],
lengths=[50, 50, 50, 50, 50],
seed=1,
)
detector = MovingWindow(bandwidth=20)
detector.fit_predict(X)
array([ 50, 100, 150, 200])
Automatic penalty calibration
import scipy.stats as st
from skchange.datasets import generate_piecewise_data
from skchange.detectors import SeededBinarySegmentation
from skchange.tuning import CalibratedDetectorFWER
# Change-free beta(2, 5) data used to calibrate the detection threshold.
X_train = generate_piecewise_data(st.beta(2, 5), lengths=300, seed=0)
# Test data with two changepoints where the beta shape changes.
X_test = generate_piecewise_data(
[st.beta(2, 5), st.beta(5, 2), st.beta(1, 10)],
lengths=100,
seed=1,
)
detector = CalibratedDetectorFWER(
SeededBinarySegmentation(),
level=0.05,
n_simulations=999,
random_state=0,
)
detector.fit(X_train)
detector.predict(X_test)
array([100, 200])
Multivariate segment anomaly detection
from skchange.datasets import generate_piecewise_normal_data
from skchange.detectors import CAPA
from skchange.interval_scorers import L2Saving
X = generate_piecewise_normal_data(
means=[0, 8, 0, 5],
lengths=[100, 20, 130, 50],
proportion_affected=[1.0, 0.1, 1.0, 0.5],
n_variables=10,
seed=1,
)
detector = CAPA(segment_saving=L2Saving())
detector.fit(X)
detector.predict_segment_anomalies(X)
array([[100, 120],
[250, 300]])
License
skchange is a free and open-source software licensed under the BSD 3-clause license.
Metadata
Release files for skchange 0.18.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| skchange-0.18.0.tar.gz | 2.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| skchange-0.18.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.9 MB
Release files / skchange-0.18.0.tar.gz
| Download URL | skchange-0.18.0.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da914922aa42fa063f87d2e444d1c4a3a63c197877bcad43011004f507149ffd
|
|
BLAKE2b-256 checksum How to use checksums |
f7035caac340b9b7b4b17a2aa8169929fcab49ad92cf9308eb4ab6cfb287c27f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / skchange-0.18.0-py3-none-any.whl
| Download URL | skchange-0.18.0-py3-none-any.whl |
|---|---|
| Size | 2.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b004eff22d21946d57a01f3b4091a7e45bb69279ad2cefc71dce43116c23369
|
|
BLAKE2b-256 checksum How to use checksums |
64435c497bad7bab575b1e22b82b2d1f8e1a05081a66cabd2c60bc46c627fb5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|