# skchange
[](https://codecov.io/gh/NorskRegnesentral/skchange)
[](https://github.com/NorskRegnesentral/skchange/actions/workflows/tests.yaml)
[](https://skchange.readthedocs.io/en/latest/?badge=latest)
[](https://github.com/sktime/sktime/blob/main/LICENSE)
[](https://github.com/psf/black)
[](https://pypi.org/project/skchange/)
[](https://pepy.tech/projects/skchange)
[skchange]((https://skchange.readthedocs.io/en/latest/)) provides [sktime](https://www.sktime.net/)-compatible change detection and changepoint-based anomaly detection algorithms.
Experimental but maturing.
## Documentation
* [Documentation](https://skchange.readthedocs.io/)
* [Notebook tutorial](https://github.com/sktime/sktime-tutorial-pydata-global-2024)
## Installation
It is recommended to install skchange with [numba](https://numba.readthedocs.io/en/stable/) for faster performance:
```sh
pip install skchange[numba]
```
Alternatively, you can install skchange without numba:
```sh
pip install skchange
```
## Quickstart
### Changepoint detection / time series segmentation
```python
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)
```
```python
ilocs
0 50
1 100
2 150
3 200
```
### Multivariate anomaly detection with variable identification
```python
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() # Looks for segments with non-zero means.
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)
```
```python
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](https://github.com/NorskRegnesentral/skchange/blob/main/LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "skchange",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13.4,>=3.10",
"maintainer_email": "Martin Tveten <tveten@nr.no>, Johannes Voll Kolst\u00f8 <jvkolsto@nr.no>",
"keywords": "data-science, machine-learning, statistics, scikit-learn, time-series, change-detection, anomaly-detection",
"author": null,
"author_email": "Martin Tveten <tveten@nr.no>",
"download_url": "https://files.pythonhosted.org/packages/e5/b1/2e73932dc933ccebf24e87282c1a49a05d9cc3da3cfda5b0174be236da59/skchange-0.14.3.tar.gz",
"platform": null,
"description": "# skchange\n\n[](https://codecov.io/gh/NorskRegnesentral/skchange)\n[](https://github.com/NorskRegnesentral/skchange/actions/workflows/tests.yaml)\n[](https://skchange.readthedocs.io/en/latest/?badge=latest)\n[](https://github.com/sktime/sktime/blob/main/LICENSE)\n[](https://github.com/psf/black)\n[](https://pypi.org/project/skchange/)\n[](https://pepy.tech/projects/skchange)\n\n\n[skchange]((https://skchange.readthedocs.io/en/latest/)) provides [sktime](https://www.sktime.net/)-compatible change detection and changepoint-based anomaly detection algorithms.\n\nExperimental but maturing.\n\n\n## Documentation\n\n* [Documentation](https://skchange.readthedocs.io/)\n* [Notebook tutorial](https://github.com/sktime/sktime-tutorial-pydata-global-2024)\n\n\n## Installation\nIt is recommended to install skchange with [numba](https://numba.readthedocs.io/en/stable/) for faster performance:\n```sh\npip install skchange[numba]\n```\n\nAlternatively, you can install skchange without numba:\n```sh\npip install skchange\n```\n\n## Quickstart\n\n### Changepoint detection / time series segmentation\n```python\nfrom skchange.change_detectors import MovingWindow\nfrom skchange.datasets import generate_piecewise_normal_data\n\ndf = generate_piecewise_normal_data(\n means=[0, 5, 10, 5, 0],\n lengths=[50, 50, 50, 50, 50],\n seed=1,\n)\n\ndetector = MovingWindow(bandwidth=20)\ndetector.fit_predict(df)\n```\n```python\n ilocs\n0 50\n1 100\n2 150\n3 200\n```\n\n### Multivariate anomaly detection with variable identification\n```python\nfrom skchange.anomaly_detectors import CAPA\nfrom skchange.anomaly_scores import L2Saving\nfrom skchange.compose.penalised_score import PenalisedScore\nfrom skchange.datasets import generate_piecewise_normal_data\nfrom skchange.penalties import make_linear_chi2_penalty\n\ndf = generate_piecewise_normal_data(\n means=[0, 8, 0, 5],\n lengths=[100, 20, 130, 50],\n proportion_affected=[1.0, 0.1, 1.0, 0.5],\n n_variables=10,\n seed=1,\n)\n\nscore = L2Saving() # Looks for segments with non-zero means.\npenalty = make_linear_chi2_penalty(score.get_model_size(1), df.shape[0], df.shape[1])\npenalised_score = PenalisedScore(score, penalty)\ndetector = CAPA(penalised_score, find_affected_components=True)\ndetector.fit_predict(df)\n```\n```python\n ilocs labels icolumns\n0 [100, 120) 1 [0]\n1 [250, 300) 2 [2, 0, 3, 1, 4]\n```\n\n## License\n\nskchange is a free and open-source software licensed under the [BSD 3-clause license](https://github.com/NorskRegnesentral/skchange/blob/main/LICENSE).\n",
"bugtrack_url": null,
"license": null,
"summary": "Sktime-compatible change and anomaly detection",
"version": "0.14.3",
"project_urls": {
"Homepage": "https://skchange.readthedocs.io"
},
"split_keywords": [
"data-science",
" machine-learning",
" statistics",
" scikit-learn",
" time-series",
" change-detection",
" anomaly-detection"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e5cdf9d7abcfdb5a6820a4aefe93012153e64bcbf4aa55979f376558a0a5ac66",
"md5": "9dfc0e7fda9c35d10e6bcdc843937156",
"sha256": "2d8d7363587fc3488cc8f27a3e6b22340b476f5ec5ca8b2fe8060a99133f66e9"
},
"downloads": -1,
"filename": "skchange-0.14.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9dfc0e7fda9c35d10e6bcdc843937156",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13.4,>=3.10",
"size": 2436094,
"upload_time": "2025-09-07T19:07:13",
"upload_time_iso_8601": "2025-09-07T19:07:13.715336Z",
"url": "https://files.pythonhosted.org/packages/e5/cd/f9d7abcfdb5a6820a4aefe93012153e64bcbf4aa55979f376558a0a5ac66/skchange-0.14.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e5b12e73932dc933ccebf24e87282c1a49a05d9cc3da3cfda5b0174be236da59",
"md5": "ac5791f5be9b292d6198352db9c541e4",
"sha256": "4ad9d0b635cad6f06e09736c5cffd1d8ea9bd82fdc701b5bb7888d30b5d961da"
},
"downloads": -1,
"filename": "skchange-0.14.3.tar.gz",
"has_sig": false,
"md5_digest": "ac5791f5be9b292d6198352db9c541e4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13.4,>=3.10",
"size": 2369860,
"upload_time": "2025-09-07T19:07:15",
"upload_time_iso_8601": "2025-09-07T19:07:15.192345Z",
"url": "https://files.pythonhosted.org/packages/e5/b1/2e73932dc933ccebf24e87282c1a49a05d9cc3da3cfda5b0174be236da59/skchange-0.14.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-07 19:07:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "skchange"
}