Code Monkey home page Code Monkey logo

tsai's Introduction


tsai

CI PyPI 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:

November, 2021

  • โœ… Implemented some of the learnings from reviewing Kaggle's latest time series competition (see Medium blog post for more details) like:
    • improved RNN initialization (based on a kernel shared by https://www.kaggle.com/junkoda)
    • added the option to pass a feature extractor to RNNPlus & TSiT (Transformer) models.
    • created a MultiConv layer that allows the concatenation of original features with the output of one or multiple convolution layers in parallel.

September, 2021

  • See our new tutorial notebook on how to track your experiments with Weights & Biases Open In Colab

  • tsai just got easier to use with the new sklearn-like APIs: TSClassifier, TSRegressor, and TSForecaster!! See this for more info.

  • New tutorial notebook on how to train your model with larger-than-memory datasets in less time achieving up to 100% GPU usage!! Open In Colab

  • tsai supports now more input formats: np.array, np.memmap, zarr, xarray, dask, list, L, ...

Previously

  • MINIROCKET a SOTA Time Series Classification model (now available in Pytorch): You can now check MiniRocket's performance in our new tutorial notebook Open In Colab

"Using this method, it is possible to train and test a classifier on all of 109 datasets from the UCR archive to state-of-the-art accuracy in less than 10 minutes." A. Dempster et al. (Dec 2020)

  • Multi-class and multi-label time series classification notebook: you can also check our new tutorial notebook: Open In Colab

  • Self-supervised learning: Learn how to leverage your unlabeled datasets Open In Colab

  • New visualization: We've also added a new PredictionDynamics callback that will display the predictions during training. This is the type of output you would get in a classification task for example:

Installation

You can install the latest stable version from pip using:

pip install tsai

Or you can install the cutting edge version of this library from github by doing:

pip install -Uqq git+https://github.com/timeseriesAI/tsai.git

Once the install is complete, you should restart your runtime and then run:

from tsai.all import *

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:

among others!

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.all import *
X, y, splits = get_classification_data('ECG200', split_data=False)
batch_tfms = TSStandardize()
clf = TSClassifier(X, y, splits=splits, arch=InceptionTimePlus, batch_tfms=batch_tfms, metrics=accuracy, cbs=ShowGraph())
clf.fit_one_cycle(100, 3e-4)
clf.export("models/clf.pkl") # make sure you set the path to a folder that already exists

Inference:

from tsai.inference import load_learner
clf = load_learner("models/clf.pkl")
probas, target, preds = clf.get_X_preds(X[splits[0]], y[splits[0]])

Multi-class, multivariate classification

Training:

from tsai.all import *
X, y, splits = get_classification_data('LSST', split_data=False)
batch_tfms = TSStandardize(by_sample=True)
mv_clf = TSClassifier(X, y, splits=splits, arch=InceptionTimePlus, batch_tfms=batch_tfms, metrics=accuracy, cbs=ShowGraph())
mv_clf.fit_one_cycle(10, 1e-2)
mv_clf.export("models/mv_clf.pkl") # make sure you set the path to a folder that already exists

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[0]], y[splits[0]])

Multivariate Regression

Training:

from tsai.all import *
X, y, splits = get_regression_data('AppliancesEnergy', split_data=False)
batch_tfms = TSStandardize(by_sample=True)
reg = TSRegressor(X, y, splits=splits, arch=TSTPlus, batch_tfms=batch_tfms, metrics=rmse, cbs=ShowGraph(), verbose=True)
reg.fit_one_cycle(100, 3e-4)
reg.export("models/reg.pkl") # make sure you set the path to a folder that already exists

Inference:

from tsai.inference import load_learner
reg = load_learner("models/reg.pkl")
raw_preds, target, preds = reg.get_X_preds(X[splits[0]], y[splits[0]])

RocketClassifier, MiniRocketClassifier, RocketRegressor and MiniRocketRegressor are somewhat different (not properly deep learning models) and are used in a slightly different way:

Training:

from tsai.all import *
from sklearn.metrics import mean_squared_error
X_train, y_train, X_test, y_test = get_regression_data('AppliancesEnergy')
rmse_scorer = make_scorer(mean_squared_error, greater_is_better=False)
mr_reg = MiniRocketRegressor(scoring=rmse_scorer)
mr_reg.fit(X_train, y_train)
mr_reg.save("minirocket_regressor")

Inference:

mr_reg = load_rocket("minirocket_regressor")
y_pred = mr_reg.predict(X_test)
mean_squared_error(y_test, y_pred, squared=False)

Univariate Forecasting

Training:

from tsai.all import *
ts = get_forecasting_time_series("Sunspots").values
X, y = SlidingWindow(60, horizon=1)(ts)
splits = TimeSplitter(235)(y) 
batch_tfms = TSStandardize()
fcst = TSForecaster(X, y, splits=splits, batch_tfms=batch_tfms, bs=512, arch=TST, metrics=mae, cbs=ShowGraph())
fcst.fit_one_cycle(50, 1e-3)
fcst.export("models/fcst.pkl") # make sure you set the path to a folder that already exists

Inference:

from tsai.inference import load_learner
fcst = load_learner("models/fcst.pkl")
raw_preds, target, preds = fcst.get_X_preds(X[splits[0]], y[splits[0]])

How to contribute to tsai?

We welcome contributions of all kinds. Development of enhancements, bug fixes, documentation, tutorial notebooks, ...

We have created a guide to help you start contributing to tsai. You can read it here.

Citing tsai

If you use tsai in your research please use the following BibTeX entry:

@Misc{tsai,
    author =       {Ignacio Oguiza},
    title =        {tsai - A state-of-the-art deep learning library for time series and sequential data},
    howpublished = {Github},
    year =         {2020},
    url =          {https://github.com/timeseriesAI/tsai}
}

tsai's People

Contributors

dependabot[bot] avatar dnth avatar geoheil avatar jeffhcross avatar oguiza avatar rkainkaryam avatar samlloydig avatar vrodriguezf avatar williamsdoug avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.