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

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

Experimental but maturing.

Now available.

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

Requires Python >= 3.9, < 3.13.

Quickstart

Changepoint detection / time series segmentation

from skchange.change_detectors.moscore import Moscore
from skchange.datasets.generate import generate_alternating_data

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

detector = Moscore(bandwidth=10)
detector.fit_predict(df)
0     49
1     99
2    149
3    199
4    249
5    299
6    349
7    399
8    449
Name: changepoint, dtype: int64

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, 119), (250, 299)]
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)
  anomaly_interval anomaly_columns
0       [100, 119]             [0]
1       [250, 299]       [2, 1, 0]

License

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