SkillAgentSearch skills...

Skchange

A python library for fast changepoint and segment anomaly detection

Install / Use

npx skills add NorskRegnesentral/skchange

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Supported Platforms

Universal

README

skchange

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

<!-- [skchange]((https://skchange.readthedocs.io/en/latest/)) provides [scikit-learn](https://scikit-learn.org/)-like changepoint detection algorithms. -->

Breaking changes expected. skchange is undergoing a significant API redesign in upcoming releases. See Issue #120 and the migration guide for details.

  • New API (recommended) is previewed in skchange.new_api.* and becomes the default in 0.17.0, when the same names move to top-level (skchange.detectors, skchange.interval_scorers, skchange.penalties, ...). Drop new_api. from imports when upgrading. Still experimental.
  • Current API (skchange.change_detectors, skchange.costs, ...) emits a FutureWarning in 0.16.x and is removed in 0.17.0.

If you need stability and the old sktime compatibility, pin to a 0.15.x release:

pip install "skchange<0.16"

Documentation

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

New API

from skchange.new_api.datasets import generate_piecewise_normal_data
from skchange.new_api.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])

Current API

from skchange.change_detectors import MovingWindow
from skchange.datasets import generate_piecewise_normal_data

df = 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(df)
   ilocs
0     50
1    100
2    150
3    200

Multivariate segment anomaly detection

New API

from skchange.new_api.datasets import generate_piecewise_normal_data
from skchange.new_api.detectors import CAPA
from skchange.new_api.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]])

Current API

from skchange.anomaly_detectors import CAPA
from skchange.anomaly_scores import L2Saving
from skchange.compose.penalised_score import PenalisedScore
from skchange.datasets import generate_piecewise_normal_data
from skchange.penalties import make_linear_chi2_penalty

df = 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,
)

score = L2Saving()
penalty = make_linear_chi2_penalty(score.get_model_size(1), df.shape[0], df.shape[1])
penalised_score = PenalisedScore(score, penalty)
detector = CAPA(penalised_score, find_affected_components=True)
detector.fit_predict(df)
        ilocs  labels         icolumns
0  [100, 120)       1              [0]
1  [250, 300)       2  [2, 0, 3, 1, 4]

License

skchange is a free and open-source software licensed under the BSD 3-clause license.

Related Skills

View on GitHub
GitHub Stars44
CategoryEducation
Updated1d ago
Forks7

Languages

Python

Security Score

95/100

Audited on Aug 7, 2026

No findings