SkillAgentSearch skills...

Tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai

Install / Use

/learn @timeseriesAI/Tsai

README

tsai

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --> <div align="center"> <img src="https://github.com/timeseriesAI/tsai/blob/main/nbs/multimedia/tsai_logo.svg?raw=true" width="50%"> </div>

<br /> <br />

CI PyPI Conda (channel
only) DOI PRs

Description

State-of-the-art Deep Learning library for Time Series and Sequences.

tsai is an open-source deep learning package built on top of Pytorch & fastai focused on state-of-the-art techniques for time series tasks like classification, regression, forecasting, imputation…

tsai is currently under active development by timeseriesAI.

What’s new:

During the last few releases, here are some of the most significant additions to tsai:

  • New models: PatchTST (Accepted by ICLR 2023), RNN with Attention (RNNAttention, LSTMAttention, GRUAttention), TabFusionTransformer, …
  • New datasets: we have increased the number of datasets you can download using tsai:
    • 128 univariate classification datasets
    • 30 multivariate classification datasets
    • 15 regression datasets
    • 62 forecasting datasets
    • 9 long term forecasting datasets
  • New tutorials: PatchTST. Based on some of your requests, we are planning to release additional tutorials on data preparation and forecasting.
  • New functionality: sklearn-type pipeline transforms, walk-foward cross validation, reduced RAM requirements, and a lot of new functionality to perform more accurate time series forecasts.
  • Pytorch 2.0 support.

Installation

Pip install

You can install the latest stable version from pip using:

pip install tsai

If you plan to develop tsai yourself, or want to be on the cutting edge, you can use an editable install. First install PyTorch, and then:

git clone https://github.com/timeseriesAI/tsai
pip install -e "tsai[dev]"

Note: starting with tsai 0.3.0 tsai will only install hard dependencies. Other soft dependencies (which are only required for selected tasks) will not be installed by default (this is the recommended approach. If you require any of the dependencies that is not installed, tsai will ask you to install it when necessary). If you still want to install tsai with all its dependencies you can do it by running:

pip install tsai[extras]

Conda install

You can also install tsai using conda (note that if you replace conda with mamba the install process will be much faster and more reliable):

conda install -c timeseriesai tsai

Documentation

Here’s the link to the documentation.

Available models:

Here’s a list with some of the state-of-the-art models available in tsai:

plus other custom models like: TransformerModel, LSTMAttention, GRUAttention, …

How to start using tsai?

To get to know the tsai package, we’d suggest you start with this notebook in Google Colab: 01_Intro_to_Time_Series_Classification It provides an overview of a time series classification task.

We have also develop many other tutorial notebooks.

To use tsai in your own notebooks, the only thing you need to do after you have installed the package is to run this:

from tsai.all import *

Examples

These are just a few examples of how you can use tsai:

Binary, univariate classification

Training:

from tsai.basics import *

X, y, splits = get_classification_data('ECG200', split_data=False)
tfms = [None, TSClassification()]
batch_tfms = TSStandardize()
clf = TSClassifier(X, y, splits=splits, path='models', arch="InceptionTimePlus", tfms=tfms, batch_tfms=batch_tfms, metrics=accuracy, cbs=ShowGraph())
clf.fit_one_cycle(100, 3e-4)
clf.export("clf.pkl") 

Inference:

from tsai.inference import load_learner

clf = load_learner("models/clf.pkl")
probas, target, preds = clf.get_X_preds(X[splits[1]], y[splits[1]])

Multi-class, multivariate classification

Training:

from tsai.basics import *

X, y, splits = get_classification_data('LSST', split_data=False)
tfms = [None, TSClassification()]
batch_tfms = TSStandardize(by_sample=True)
mv_clf = TSClassifier(X, y, splits=splits, path='models', arch="InceptionTimePlus", tfms=tfms, batch_tfms=batch_tfms, metrics=accuracy, cbs=ShowGraph())
mv_clf.fit_one_cycle(10, 1e-2)
mv_clf.export("mv_clf.pkl")

Inference:

from tsai.inference import load_learner

mv_clf = load_learner("models/mv_clf.pkl")
probas, target, preds = mv_clf.get_X_preds(X[splits[1]], y[splits[1]])

Multivariate Regression

Training:

from tsai.basics import *

X, y, splits = get_regression_data('AppliancesEnergy', split_data=False)
tfms = [None, TSRegression()]
batch_tfms = TSStandardize(by_sample=True)
reg = TSRegressor(X, y, splits=splits, path='models', arch="TSTPlu
View on GitHub
GitHub Stars6.0k
CategoryEducation
Updated6h ago
Forks718

Languages

Jupyter Notebook

Security Score

100/100

Audited on Mar 21, 2026

No findings