{"id":13415361,"url":"https://github.com/tslearn-team/tslearn","last_synced_at":"2025-05-13T22:01:52.506Z","repository":{"id":37073492,"uuid":"90264407","full_name":"tslearn-team/tslearn","owner":"tslearn-team","description":"The machine learning toolkit for time series analysis in Python","archived":false,"fork":false,"pushed_at":"2024-07-01T09:07:36.000Z","size":7450,"stargazers_count":2971,"open_issues_count":140,"forks_count":346,"subscribers_count":58,"default_branch":"main","last_synced_at":"2025-04-29T13:17:19.664Z","etag":null,"topics":["dtw","dynamic-time-warping","machine-learning","machine-learning-algorithms","machinelearning","python","time-series","time-series-analysis","time-series-classification","time-series-clustering","timeseries"],"latest_commit_sha":null,"homepage":"https://tslearn.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tslearn-team.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-05-04T13:08:13.000Z","updated_at":"2025-04-27T13:48:19.000Z","dependencies_parsed_at":"2022-06-24T20:04:20.175Z","dependency_job_id":"861db40e-986d-46a8-9cb5-4a212a9101c2","html_url":"https://github.com/tslearn-team/tslearn","commit_stats":{"total_commits":1472,"total_committers":46,"mean_commits":32.0,"dds":0.3125,"last_synced_commit":"da26819c0ea281ca39a35429cbd308fc80a8b7bc"},"previous_names":["rtavenar/tslearn"],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslearn-team%2Ftslearn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslearn-team%2Ftslearn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslearn-team%2Ftslearn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tslearn-team%2Ftslearn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tslearn-team","download_url":"https://codeload.github.com/tslearn-team/tslearn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036807,"owners_count":22003651,"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":["dtw","dynamic-time-warping","machine-learning","machine-learning-algorithms","machinelearning","python","time-series","time-series-analysis","time-series-classification","time-series-clustering","timeseries"],"created_at":"2024-07-30T21:00:47.591Z","updated_at":"2025-05-13T22:01:52.442Z","avatar_url":"https://github.com/tslearn-team.png","language":"Python","funding_links":[],"categories":["相关包","Python","Others","Time Series Data","\u003cspan id=\"head7\"\u003e2.2. (Deep Learning based) Time Series Analysis\u003c/span\u003e","Time Series","Time-Series \u0026 Financial","时间序列","Curated List","📦 Packages","Related Software"],"sub_categories":["预测","Tools \u0026 Projects","Others","网络服务_其他","Time Series Analysis","Python","Time-Series Analysis"],"readme":"\u003c!-- Our title --\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003etslearn \u003c/h3\u003e\n\u003c/div\u003e\n\n\u003c!-- Short description --\u003e\n\u003cp align=\"center\"\u003e\n   The machine learning toolkit for time series analysis in Python\n\u003c/p\u003e\n\n\u003c!-- The badges --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://badge.fury.io/py/tslearn\"\u003e\n        \u003cimg alt=\"PyPI\" src=\"https://badge.fury.io/py/tslearn.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://tslearn.readthedocs.io/en/stable/?badge=stable\"\u003e\n        \u003cimg alt=\"Documentation\" src=\"https://readthedocs.org/projects/tslearn/badge/?version=stable\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://dev.azure.com/romaintavenard/tslearn/_build\"\u003e\n        \u003cimg alt=\"Build (Azure Pipelines)\" src=\"https://dev.azure.com/romaintavenard/tslearn/_apis/build/status/tslearn-team.tslearn?branchName=main\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/tslearn-team/tslearn\"\u003e\n        \u003cimg alt=\"Codecov\" src=\"https://codecov.io/gh/tslearn-team/tslearn/branch/main/graph/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pepy.tech/project/tslearn\"\u003e\n        \u003cimg alt=\"Downloads\" src=\"https://pepy.tech/badge/tslearn\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003c!-- Draw horizontal rule --\u003e\n\u003chr\u003e\n\n\u003c!-- Table of content --\u003e\n\n| Section | Description |\n|-|-|\n| [Installation](#installation) | Installing the dependencies and tslearn |\n| [Getting started](#getting-started) | A quick introduction on how to use tslearn |\n| [Available features](#available-features) | An extensive overview of tslearn's functionalities |\n| [Documentation](#documentation) | A link to our API reference and a gallery of examples |\n| [Contributing](#contributing) | A guide for heroes willing to contribute |\n| [Citation](#referencing-tslearn) | A citation for tslearn for scholarly articles |\n\n## Installation\nThere are different alternatives to install tslearn:\n* PyPi: `python -m pip install tslearn`\n* Conda: `conda install -c conda-forge tslearn`\n* Git: `python -m pip install https://github.com/tslearn-team/tslearn/archive/main.zip`\n\nIn order for the installation to be successful, the required dependencies must be installed. For a more detailed guide on how to install tslearn, please see the [Documentation](https://tslearn.readthedocs.io/en/stable/?badge=stable#installation).\n\n## Getting started\n\n### 1. Getting the data in the right format\ntslearn expects a time series dataset to be formatted as a 3D `numpy` array. The three dimensions correspond to the number of time series, the number of measurements per time series and the number of dimensions respectively (`n_ts, max_sz, d`). In order to get the data in the right format, different solutions exist:\n* [You can use the utility functions such as `to_time_series_dataset`.](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.utils.html#module-tslearn.utils)\n* [You can convert from other popular time series toolkits in Python.](https://tslearn.readthedocs.io/en/stable/integration_other_software.html)\n* [You can load any of the UCR datasets in the required format.](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.datasets.html#module-tslearn.datasets)\n* [You can generate synthetic data using the `generators` module.](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.generators.html#module-tslearn.generators)\n\nIt should further be noted that tslearn [supports variable-length timeseries](https://tslearn.readthedocs.io/en/stable/variablelength.html).\n\n```python3\n\u003e\u003e\u003e from tslearn.utils import to_time_series_dataset\n\u003e\u003e\u003e my_first_time_series = [1, 3, 4, 2]\n\u003e\u003e\u003e my_second_time_series = [1, 2, 4, 2]\n\u003e\u003e\u003e my_third_time_series = [1, 2, 4, 2, 2]\n\u003e\u003e\u003e X = to_time_series_dataset([my_first_time_series,\n                                my_second_time_series,\n                                my_third_time_series])\n\u003e\u003e\u003e y = [0, 1, 1]\n```\n\n### 2. Data preprocessing and transformations\nOptionally, tslearn has several utilities to preprocess the data. In order to facilitate the convergence of different algorithms, you can [scale time series](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.preprocessing.html#module-tslearn.preprocessing). Alternatively, in order to speed up training times, one can [resample](https://tslearn.readthedocs.io/en/stable/gen_modules/preprocessing/tslearn.preprocessing.TimeSeriesResampler.html#tslearn.preprocessing.TimeSeriesResampler) the data or apply a [piece-wise transformation](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.piecewise.html#module-tslearn.piecewise).\n\n```python3\n\u003e\u003e\u003e from tslearn.preprocessing import TimeSeriesScalerMinMax\n\u003e\u003e\u003e X_scaled = TimeSeriesScalerMinMax().fit_transform(X)\n\u003e\u003e\u003e print(X_scaled)\n[[[0.] [0.667] [1.] [0.333] [nan]]\n [[0.] [0.333] [1.] [0.333] [nan]]\n [[0.] [0.333] [1.] [0.333] [0.333]]]\n```\n\n### 3. Training a model\n\nAfter getting the data in the right format, a model can be trained. Depending on the use case, tslearn supports different tasks: classification, clustering and regression. For an extensive overview of possibilities, check out our [gallery of examples](https://tslearn.readthedocs.io/en/stable/auto_examples/index.html).\n\n```python3\n\u003e\u003e\u003e from tslearn.neighbors import KNeighborsTimeSeriesClassifier\n\u003e\u003e\u003e knn = KNeighborsTimeSeriesClassifier(n_neighbors=1)\n\u003e\u003e\u003e knn.fit(X_scaled, y)\n\u003e\u003e\u003e print(knn.predict(X_scaled))\n[0 1 1]\n```\n\nAs can be seen, the models in tslearn follow the same API as those of the well-known scikit-learn. Moreover, they are fully compatible with it, allowing to use different scikit-learn utilities such as [hyper-parameter tuning and pipelines](https://tslearn.readthedocs.io/en/stable/auto_examples/neighbors/plot_knnts_sklearn.html).\n\n### 4. More analyses\n\ntslearn further allows to perform all different types of analysis. Examples include [calculating barycenters](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.barycenters.html#module-tslearn.barycenters) of a group of time series or calculate the distances between time series using a [variety of distance metrics](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.metrics.html#module-tslearn.metrics).\n\n## Available features\n\n| data                                                                                                                                                                                         | processing                                                                                                              | clustering                                                                                                                                                       | classification                                                                                                                                                                          | regression                                                                                                                                                                           | metrics                                                                                                                              |\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| [UCR Datasets](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.datasets.html#module-tslearn.datasets)                                                                           | [Scaling](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.preprocessing.html#module-tslearn.preprocessing) | [TimeSeriesKMeans](https://tslearn.readthedocs.io/en/stable/gen_modules/clustering/tslearn.clustering.TimeSeriesKMeans.html#tslearn.clustering.TimeSeriesKMeans) | [KNN Classifier](https://tslearn.readthedocs.io/en/stable/gen_modules/neighbors/tslearn.neighbors.KNeighborsTimeSeriesClassifier.html#tslearn.neighbors.KNeighborsTimeSeriesClassifier) | [KNN Regressor](https://tslearn.readthedocs.io/en/stable/gen_modules/neighbors/tslearn.neighbors.KNeighborsTimeSeriesRegressor.html#tslearn.neighbors.KNeighborsTimeSeriesRegressor) | [Dynamic Time Warping](https://tslearn.readthedocs.io/en/stable/gen_modules/metrics/tslearn.metrics.dtw.html#tslearn.metrics.dtw)    |\n| [Generators](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.generators.html#module-tslearn.generators)                                                                         | [Piecewise](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.piecewise.html#module-tslearn.piecewise)       | [KShape](https://tslearn.readthedocs.io/en/stable/gen_modules/clustering/tslearn.clustering.KShape.html#tslearn.clustering.KShape)                               | [TimeSeriesSVC](https://tslearn.readthedocs.io/en/stable/gen_modules/svm/tslearn.svm.TimeSeriesSVC.html#tslearn.svm.TimeSeriesSVC)                                                      | [TimeSeriesSVR](https://tslearn.readthedocs.io/en/stable/gen_modules/svm/tslearn.svm.TimeSeriesSVR.html#tslearn.svm.TimeSeriesSVR)                                                   | [Global Alignment Kernel](https://tslearn.readthedocs.io/en/stable/gen_modules/metrics/tslearn.metrics.gak.html#tslearn.metrics.gak) |\n| Conversion([1](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.utils.html#module-tslearn.utils), [2](https://tslearn.readthedocs.io/en/stable/integration_other_software.html)) |                                                                                                                         | [KernelKmeans](https://tslearn.readthedocs.io/en/stable/gen_modules/clustering/tslearn.clustering.KernelKMeans.html#tslearn.clustering.KernelKMeans)             | [LearningShapelets](https://tslearn.readthedocs.io/en/stable/gen_modules/shapelets/tslearn.shapelets.LearningShapelets.html)                                    | [MLP](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.neural_network.html#module-tslearn.neural_network)                                                                | [Barycenters](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.barycenters.html#module-tslearn.barycenters)              |\n|                                                                                                                                                                                              |                                                                                                                         |                                                                                                                                                                  | [Early Classification](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.early_classification.html#module-tslearn.early_classification)                                      |                                                                                                                                                                                      | [Matrix Profile](https://tslearn.readthedocs.io/en/stable/gen_modules/tslearn.matrix_profile.html#module-tslearn.matrix_profile)     |\n\n\n## Documentation\n\nThe documentation is hosted at [readthedocs](http://tslearn.readthedocs.io/en/stable/index.html). It includes an [API](https://tslearn.readthedocs.io/en/stable/reference.html), [gallery of examples](https://tslearn.readthedocs.io/en/stable/auto_examples/index.html) and a [user guide](https://tslearn.readthedocs.io/en/stable/user_guide/userguide.html).\n\n## Contributing\n\nIf you would like to contribute to `tslearn`, please have a look at [our contribution guidelines](CONTRIBUTING.md). A list of interesting TODO's can be found [here](https://github.com/tslearn-team/tslearn/issues?utf8=✓\u0026q=is%3Aissue%20is%3Aopen%20label%3A%22new%20feature%22%20). **If you want other ML methods for time series to be added to this TODO list, do not hesitate to [open an issue](https://github.com/tslearn-team/tslearn/issues/new/choose)!**\n\n## Referencing tslearn\n\nIf you use `tslearn` in a scientific publication, we would appreciate citations:\n\n```bibtex\n@article{JMLR:v21:20-091,\n  author  = {Romain Tavenard and Johann Faouzi and Gilles Vandewiele and \n             Felix Divo and Guillaume Androz and Chester Holtz and \n             Marie Payne and Roman Yurchak and Marc Ru{\\ss}wurm and \n             Kushal Kolar and Eli Woods},\n  title   = {Tslearn, A Machine Learning Toolkit for Time Series Data},\n  journal = {Journal of Machine Learning Research},\n  year    = {2020},\n  volume  = {21},\n  number  = {118},\n  pages   = {1-6},\n  url     = {http://jmlr.org/papers/v21/20-091.html}\n}\n```\n\n#### Acknowledgments\nAuthors would like to thank Mathieu Blondel for providing code for [Kernel k-means](https://gist.github.com/mblondel/6230787) and [Soft-DTW](https://github.com/mblondel/soft-dtw), and to Mehran Maghoumi for his [`torch`-compatible implementation of SoftDTW](https://github.com/Maghoumi/pytorch-softdtw-cuda).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftslearn-team%2Ftslearn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftslearn-team%2Ftslearn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftslearn-team%2Ftslearn/lists"}