Skip to content

skchange provides sktime-compatible change detection and changepoint-based anomaly detection algorithms

License

Notifications You must be signed in to change notification settings

NorskRegnesentral/skchange

Repository files navigation

codecov tests docs BSD 3-clause !black Python

skchange provides sktime-compatible change detection and changepoint-based anomaly detection algorithms.

Experimental but maturing.

Documentation

Docs | Notebook tutorial

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.change_detectors.moving_window import MovingWindow
from skchange.datasets.generate import generate_alternating_data

df = generate_alternating_data(n_segments=10, segment_length=50, mean=5, random_state=1)

detector = MovingWindow(bandwidth=10)
detector.fit_predict(df)
   ilocs
0     50
1    100
2    150
3    200
4    250
5    300
6    350
7    400
8    450

Multivariate anomaly detection

import numpy as np
from skchange.anomaly_detectors import MVCAPA
from skchange.datasets.generate import generate_anomalous_data

n = 300
anomalies = [(100, 120), (250, 300)]
means = [[8.0, 0.0, 0.0], [2.0, 3.0, 5.0]]
df = generate_anomalous_data(n, anomalies, means, random_state=3)

detector = MVCAPA()
detector.fit_predict(df)
        ilocs  labels   icolumns
0  [100, 120)       1        [0]
1  [250, 300)       2  [2, 1, 0]

License

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