tslearn

The machine learning toolkit for time series analysis in Python

https://github.com/tslearn-team/tslearn

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    5 of 43 committers (11.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.7%) to scientific vocabulary

Keywords

dtw dynamic-time-warping machine-learning machine-learning-algorithms machinelearning python time-series time-series-analysis time-series-classification time-series-clustering timeseries

Keywords from Contributors

wasserstein-barycenter data-mining closember
Last synced: 6 months ago · JSON representation

Repository

The machine learning toolkit for time series analysis in Python

Basic Info
Statistics
  • Stars: 3,030
  • Watchers: 59
  • Forks: 355
  • Open Issues: 117
  • Releases: 22
Topics
dtw dynamic-time-warping machine-learning machine-learning-algorithms machinelearning python time-series time-series-analysis time-series-classification time-series-clustering timeseries
Created almost 9 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

tslearn logo

The machine learning toolkit for time series analysis in Python

PyPI Python 3.9+ Documentation Build (Azure Pipelines) Codecov Downloads


| Section | Description | |-|-| | Installation | Installing the dependencies and tslearn | | Getting started | A quick introduction on how to use tslearn | | Available features | An extensive overview of tslearn's functionalities | | Documentation | A link to our API reference and a gallery of examples | | Contributing | A guide for heroes willing to contribute | | Citation | A citation for tslearn for scholarly articles |

Installation

There are different alternatives to install tslearn: * PyPi: python -m pip install tslearn * Conda: conda install -c conda-forge tslearn * Git: python -m pip install https://github.com/tslearn-team/tslearn/archive/main.zip

In 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.

Getting started

1. Getting the data in the right format

tslearn 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: * You can use the utility functions such as to_time_series_dataset. * You can convert from other popular time series toolkits in Python. * You can load any of the UCR datasets in the required format. * You can generate synthetic data using the generators module.

It should further be noted that tslearn supports variable-length timeseries.

```python3

from tslearn.utils import totimeseriesdataset myfirsttimeseries = [1, 3, 4, 2] mysecondtimeseries = [1, 2, 4, 2] mythirdtimeseries = [1, 2, 4, 2, 2] X = totimeseriesdataset([myfirsttimeseries, mysecondtimeseries, mythirdtimeseries]) y = [0, 1, 1] ```

2. Data preprocessing and transformations

Optionally, tslearn has several utilities to preprocess the data. In order to facilitate the convergence of different algorithms, you can scale time series. Alternatively, in order to speed up training times, one can resample the data or apply a piece-wise transformation.

```python3

from tslearn.preprocessing import TimeSeriesScalerMinMax Xscaled = TimeSeriesScalerMinMax().fittransform(X) print(X_scaled) [[[0.] [0.667] [1.] [0.333] [nan]] [[0.] [0.333] [1.] [0.333] [nan]] [[0.] [0.333] [1.] [0.333] [0.333]]] ```

3. Training a model

After 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.

```python3

from tslearn.neighbors import KNeighborsTimeSeriesClassifier knn = KNeighborsTimeSeriesClassifier(nneighbors=1) knn.fit(Xscaled, y) print(knn.predict(X_scaled)) [0 1 1] ```

As 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.

4. More analyses

tslearn further allows to perform all different types of analysis. Examples include calculating barycenters of a group of time series or calculate the distances between time series using a variety of distance metrics.

Available features

| data | processing | clustering | classification | regression | metrics | |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------| | UCR Datasets | Scaling | TimeSeriesKMeans | KNN Classifier | KNN Regressor | Dynamic Time Warping | | Generators | Piecewise | KShape | TimeSeriesSVC | TimeSeriesSVR | Global Alignment Kernel | | Conversion(1, 2) | | KernelKmeans | LearningShapelets | MLP | Barycenters | | | | | Early Classification | | Matrix Profile |

Documentation

The documentation is hosted at readthedocs. It includes an API, gallery of examples and a user guide.

Contributing

If you would like to contribute to tslearn, please have a look at our contribution guidelines. A list of interesting TODO's can be found here. If you want other ML methods for time series to be added to this TODO list, do not hesitate to open an issue!

Referencing tslearn

If you use tslearn in a scientific publication, we would appreciate citations:

bibtex @article{JMLR:v21:20-091, author = {Romain Tavenard and Johann Faouzi and Gilles Vandewiele and Felix Divo and Guillaume Androz and Chester Holtz and Marie Payne and Roman Yurchak and Marc Ru{\ss}wurm and Kushal Kolar and Eli Woods}, title = {Tslearn, A Machine Learning Toolkit for Time Series Data}, journal = {Journal of Machine Learning Research}, year = {2020}, volume = {21}, number = {118}, pages = {1-6}, url = {http://jmlr.org/papers/v21/20-091.html} }

Acknowledgments

Authors would like to thank Mathieu Blondel for providing code for Kernel k-means and Soft-DTW, and to Mehran Maghoumi for his torch-compatible implementation of SoftDTW.

Owner

  • Name: tslearn-team
  • Login: tslearn-team
  • Kind: organization

GitHub Events

Total
  • Create event: 29
  • Release event: 4
  • Issues event: 31
  • Watch event: 127
  • Delete event: 30
  • Issue comment event: 42
  • Push event: 107
  • Pull request review comment event: 2
  • Pull request review event: 5
  • Pull request event: 43
  • Fork event: 19
Last Year
  • Create event: 29
  • Release event: 4
  • Issues event: 31
  • Watch event: 127
  • Delete event: 30
  • Issue comment event: 42
  • Push event: 107
  • Pull request review comment event: 2
  • Pull request review event: 5
  • Pull request event: 43
  • Fork event: 19

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 1,476
  • Total Committers: 43
  • Avg Commits per committer: 34.326
  • Development Distribution Score (DDS): 0.314
Past Year
  • Commits: 2
  • Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Romain Tavenard r****d@u****r 1,012
Gilles Vandewiele g****e@u****e 203
Yann Cabanes y****s@g****m 39
johann.faouzi j****i@i****g 33
Roman Yurchak r****k@p****e 27
Johann Faouzi j****i@g****m 25
painblanc_f f****3 20
kushalkolar k****r@g****m 20
Felix Divo f****o@g****m 19
Arne Küderle a****e@g****m 12
Scott Page 6****1 10
Romain Fayat r****t@g****m 9
guillaume g****z@g****m 6
jscheithe j****e@g****e 5
Chester Holtz c****z@g****m 4
eliwoods e****i@e****m 3
yichang wang y****g@i****r 2
Steven Elsworth s****h@s****m 2
daniel d****t@i****m 1
Peter Majchrak pm@l****m 1
Marie Payne m****e@c****a 1
Tom Crasset t****t@g****m 1
Thusitha Thilina Dayaratne t****a@g****m 1
Rémi Flamary r****y@g****m 1
Pierre Navaro p****o@u****r 1
Mikhail w****2@g****m 1
Marc Rußwurm m****m@t****e 1
Luca Kubin l****n@g****m 1
Konstantin Stadler k****r@n****o 1
Jacob Chuslo 4****j 1
and 13 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 113
  • Total pull requests: 109
  • Average time to close issues: 11 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 91
  • Total pull request authors: 27
  • Average comments per issue: 3.0
  • Average comments per pull request: 4.41
  • Merged pull requests: 63
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 16
  • Pull requests: 25
  • Average time to close issues: 13 days
  • Average time to close pull requests: 1 day
  • Issue authors: 7
  • Pull request authors: 4
  • Average comments per issue: 0.31
  • Average comments per pull request: 0.4
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • charavelg (6)
  • AnnaBobasheva (4)
  • GillesVandewiele (4)
  • NimaSarajpoor (3)
  • fkiraly (2)
  • petoknm (2)
  • NAThompson (2)
  • imwihfm (2)
  • yasirroni (2)
  • RadhikaaM (2)
  • delacylab (2)
  • rtavenar (2)
  • StefanR44 (2)
  • idrismunir15 (1)
  • DanielDondorp (1)
Pull Request Authors
  • YannCabanes (54)
  • charavelg (21)
  • rtavenar (3)
  • GillesVandewiele (2)
  • petoknm (2)
  • kashee337 (2)
  • seigpe (2)
  • r-millington (2)
  • adesvall (2)
  • Ivorforce (2)
  • yasirroni (1)
  • MarieSacksick (1)
  • NimaSarajpoor (1)
  • ecederstrand (1)
  • Gjacquenot (1)
Top Labels
Issue Labels
bug (45) new feature (31) question (7) good first issue (6) metrics (4) help wanted (3) help welcome (1) KShape (1) documentation (1) shapelet (1) preprocessing (1)
Pull Request Labels
dependencies (1) python (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 407,053 last-month
  • Total docker downloads: 4,160
  • Total dependent packages: 38
    (may contain duplicates)
  • Total dependent repositories: 316
    (may contain duplicates)
  • Total versions: 116
  • Total maintainers: 2
pypi.org: tslearn

A machine learning toolkit dedicated to time-series data

  • Versions: 81
  • Dependent Packages: 37
  • Dependent Repositories: 315
  • Downloads: 407,030 Last month
  • Docker Downloads: 4,160
Rankings
Dependent packages count: 0.5%
Downloads: 0.6%
Dependent repos count: 0.8%
Average: 1.3%
Stargazers count: 1.4%
Docker downloads count: 1.5%
Forks count: 2.9%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/tslearn-team/tslearn
  • Versions: 33
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: tslearn-m1

A machine learning toolkit dedicated to time-series data

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 23 Last month
Rankings
Stargazers count: 1.4%
Forks count: 2.8%
Dependent packages count: 2.9%
Average: 13.5%
Dependent repos count: 23.9%
Downloads: 36.5%
Maintainers (1)
Last synced: about 1 year ago

Dependencies

docs/requirements_rtd.txt pypi
  • Cython *
  • Pygments *
  • ipykernel *
  • matplotlib *
  • nbsphinx *
  • numba *
  • numpy *
  • numpydoc *
  • pillow *
  • scikit-learn *
  • scipy *
  • sphinx >=1.6.1
  • sphinx-gallery *
  • sphinx_bootstrap_theme *
  • tensorflow >=2
requirements.txt pypi
  • Cython *
  • cesium *
  • h5py *
  • joblib >=0.12
  • numba *
  • numpy *
  • pandas *
  • scikit-learn *
  • scipy *
  • tensorflow >=2
requirements_build.txt pypi
  • Cython *
  • h5py *
  • joblib >=0.12
  • numba *
  • numpy *
  • scikit-learn <0.24
  • scipy *
requirements_nocast.txt pypi
  • Cython *
  • h5py *
  • joblib >=0.12
  • numba *
  • numpy *
  • scikit-learn *
  • scipy *
  • tensorflow >=2
setup.py pypi
  • Cython *
  • joblib *
  • numba *
  • numpy *
  • scikit-learn *
  • scipy *