Skip to main content

skchange

codecov tests docs BSD 3-clause !black Python PyPI Downloads

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_calib = generate_piecewise_data(st.beta(2, 5), lengths=300, seed=0)

# Test data with two changepoints where the beta shape changes.
X = generate_piecewise_data(
    [st.beta(2, 5), st.beta(5, 2), st.beta(1, 10)],
    lengths=100,
    seed=1,
)

cal = CalibratedDetectorFWER(
    SeededBinarySegmentation(),
    level=0.05,
    n_simulations=999,
    random_state=0,
)
cal.fit(X_calib)
cal.predict(X)
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.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skchange 0.17.0
File Size Uploaded
skchange-0.17.0.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for skchange 0.17.0
File Interpreter ABI Platform
skchange-0.17.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.9 MB

Release files / skchange-0.17.0.tar.gz

Download URL skchange-0.17.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
0f214a94f0a5023ab6a8c0be265fec1623dc8dd78d44c866063116d767428a03
BLAKE2b-256 checksum
How to use checksums
e5e40e35c992209e2c52fc9069afa50d86f09664bbcc5b91c9be0452f114a587
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.17.0-py3-none-any.whl

Download URL skchange-0.17.0-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7cce60d4846963055937ab397d3824f3742a73cec2e2ce375095f0330214275c
BLAKE2b-256 checksum
How to use checksums
6cc0d6bca2b49f82090fa467fee4c481ac7fafd5ffa49d8b58bbff067464423c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

0.18.0

2 release files

This release

0.17.0 This release

2 release files

0.14.0

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page