{"id":13703317,"url":"https://github.com/ermshaua/time-series-segmentation-benchmark","last_synced_at":"2025-05-05T07:30:52.781Z","repository":{"id":86518925,"uuid":"426244312","full_name":"ermshaua/time-series-segmentation-benchmark","owner":"ermshaua","description":"This repository contains the time series segmentation benchmark (TSSB).","archived":false,"fork":false,"pushed_at":"2025-03-27T12:52:50.000Z","size":19790,"stargazers_count":66,"open_issues_count":1,"forks_count":16,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T13:40:47.789Z","etag":null,"topics":["change-point","change-point-detection","data-mining","data-science","machine-learning","python","research","science","segmentation","time-series","time-series-analysis","time-series-data-mining","time-series-segmentation","unsupervised-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ermshaua.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-09T13:41:27.000Z","updated_at":"2025-03-27T12:52:55.000Z","dependencies_parsed_at":"2024-11-13T10:41:38.730Z","dependency_job_id":null,"html_url":"https://github.com/ermshaua/time-series-segmentation-benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermshaua%2Ftime-series-segmentation-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermshaua%2Ftime-series-segmentation-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermshaua%2Ftime-series-segmentation-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermshaua%2Ftime-series-segmentation-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ermshaua","download_url":"https://codeload.github.com/ermshaua/time-series-segmentation-benchmark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252458345,"owners_count":21751021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-point","change-point-detection","data-mining","data-science","machine-learning","python","research","science","segmentation","time-series","time-series-analysis","time-series-data-mining","time-series-segmentation","unsupervised-learning"],"created_at":"2024-08-02T21:00:53.355Z","updated_at":"2025-05-05T07:30:47.771Z","avatar_url":"https://github.com/ermshaua.png","language":"Jupyter Notebook","funding_links":[],"categories":["PFMs for Video Data"],"sub_categories":[],"readme":"# Time Series Segmentation Benchmark (TSSB)\nThe problem of time series segmentation (TSS) is to find a meaningful segmentation of a time series (TS) that captures a data-generating process with distinct states and transitions. We consider a segmentation meaningful, if the change points (CPs) between two consecutive segments correspond to state transitions in the associated process. \n\nThis repository contains the time series segmentation benchmark (TSSB). It currently contains 75 annotated TS with 1-9 segments. Each TS is constructed from one of the \u003ca target=\"_blank\" href=\"http://timeseriesclassification.com/\"\u003eUEA \u0026 UCR time series classification\u003c/a\u003e datasets. We group TS by label and concatenate them to create segments with distinctive temporal patterns and statistical properties. We annotate the offsets at which we concatenated the segments as CPs. Addtionally, we apply resampling to control the dataset resolution and add approximate, hand-selected window sizes that are able to capture temporal patterns. We have a \u003ca target=\"_blank\" href=\"https://github.com/ermshaua/time-series-segmentation-benchmark/blob/main/tssb/notebooks/dataset_generation.ipynb\"\u003ejupyter notebook\u003c/a\u003e that shows how to automatically perform the transformation.   \n\n## Installation\nYou can install the TSSB with PyPi:\n`python -m pip install git+https://github.com/ermshaua/time-series-segmentation-benchmark` \n\n## Citation\nIf you use the TSSB in your scientific publication, we would appreciate the following citations:\n\n```\n@article{clasp2023,\n  title={ClaSP: parameter-free time series segmentation},\n  author={Arik Ermshaus and Patrick Sch{\\\"a}fer and Ulf Leser},\n  journal={Data Mining and Knowledge Discovery},\n  year={2023},\n}\n\n@inproceedings{clasp2021,\n  title={ClaSP - Time Series Segmentation},\n  author={Sch{\\\"a}fer, Patrick and Ermshaus, Arik and Leser, Ulf},\n  booktitle={CIKM},\n  year={2021}\n}\n```\n\n## Results\n\nWe have evaluated 7 time series segmentation algorithms using the TSSB. The following table summarises the average segmentation Covering (higher is better) and the corresponding mean ranks. Evaluation details are in the \u003ca target=\"_blank\" href=\"https://doi.org/10.1007/s10618-023-00923-x\"\u003epaper\u003c/a\u003e. The raw result sheet and an evaluation notebook are in the \u003ca target=\"_blank\" href=\"https://github.com/ermshaua/time-series-segmentation-benchmark/tree/main/tssb/notebooks\"\u003enotebooks\u003c/a\u003e folder.\n\n| Segmentation Algorithm | Mean Accuracy | Mean Rank | Wins \u0026 Ties |\n|------------------------|---------------| --------- |-------------\n| ClaSP                  |  85.47%             | 1.5       | 54/75         |\n| BinSeg                 |  57.49%             | 2.8       | 12/75         |\n| PELT                   |  58.1%             | 2.9       | 12/75         |\n| FLOSS                  |  56.74%             | 3.1       | 12/75         |\n| Window                 |  40.1%             | 4.3       | 7/75         |\n| BOCD                   |  44.88%             | 4.3       | 6/75         |\n| ESPRESSO               |  44.36%             | 4.6       | 4/75         |\n\nThe mean ranks are visualized in the followind critical difference (CD) diagram. Not significantly different algorithms are connected with a horizontal bar based\non a Nemenyi two tailed significance test with a = 0.05. The boxplot illustrates the summary statistics.\n\n\u003cp float=\"left\"\u003e\n  \u003cimg src=\"tssb/ranks.png\" width=\"300\" /\u003e\n  \u003cimg src=\"tssb/boxplot.png\" width=\"300\" /\u003e\n\u003c/p\u003e\n\n## Basic Usage\nLet's first import methods to load TS from the benchmark and to evaluate TSS algorithms. As an example, we also import our segmentation algorithm ClaSP from \u003ca target=\"_blank\" href=\"https://github.com/ermshaua/claspy\"\u003eclaspy\u003c/a\u003e. \n\n```python3\n\u003e\u003e\u003e from tssb.utils import load_time_series_segmentation_datasets\n\u003e\u003e\u003e from tssb.evaluation import covering\n\u003e\u003e\u003e from claspy.segmentation import BinaryClaSPSegmentation\n```\n\nWe can now load the entire benchmark (75 TS) as a pandas dataframe using \n\n```python3\n\u003e\u003e\u003e tssb = load_time_series_segmentation_datasets()\n```\n\nor a selection of TS by specifying the `names` attribute using\n\n```python3\n\u003e\u003e\u003e tssb = load_time_series_segmentation_datasets(names=[\"ArrowHead\", \"InlineSkate\", \"Plane\"])\n```\n\nThe dataframe `tssb` contains (TS name, window size, CPs, TS) rows and can now be iterated to evaluate a TSS algorithm.\n\n```python3\n\u003e\u003e\u003e for _, (ts_name, window_size, cps, ts) in tssb.iterrows():\n\u003e\u003e\u003e   found_cps = BinaryClaSPSegmentation().fit_predict(ts)\n\u003e\u003e\u003e   score = covering({0: cps}, found_cps, ts.shape[0])\n\u003e\u003e\u003e   print(f\"Time Series: {ts_name}: True Change Points: {cps}, Found Change Points: {found_cps.tolist()}, Score: {score}\")\n```\n\nIn a similar fashion, you can evaluate your TSS algorithm and compare results. For more details, see the example \u003ca href=\"https://github.com/ermshaua/time-series-segmentation-benchmark/tree/main/tssb/notebooks\"\u003enotebooks\u003c/a\u003e.\n\n## Visualizations\n\nSee the following example TS to get an overview of the TSSB. You can find more images in the \u003ca href=\"https://github.com/ermshaua/time-series-segmentation-benchmark/tree/main/tssb/visualizations\"\u003evisualizations\u003c/a\u003e folder.\n\n![image](tssb/visualizations/ArrowHead.png)\n\n![image](tssb/visualizations/InlineSkate.png)\n\n![image](tssb/visualizations/Plane.png)\n\nIn order to create a visualization of your predicted segmentation, you can use the following code.\n\n```python3\n\u003e\u003e\u003e import matplotlib.pyplot as plt\n\u003e\u003e\u003e from tssb.utils import visualize_time_series\n\u003e\u003e\u003e fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)\n\u003e\u003e\u003e plt.show()\n```\n\n![image](tssb/plane_example_segmentation.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermshaua%2Ftime-series-segmentation-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fermshaua%2Ftime-series-segmentation-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermshaua%2Ftime-series-segmentation-benchmark/lists"}