Skip to main content
Logo

Predict your time series the easiest way

PyPI Version Python versions Downloads

Coverage Test passing Docs publish License

Telegram Contributors Stars

Documentation | Tutorials | Contribution Guide | Release Notes

ETNA is an easy-to-use time series forecasting framework. It includes built in toolkits for time series preprocessing, feature generation, a variety of predictive models with unified interface - from classic machine learning to SOTA neural networks, models combination methods and smart backtesting. ETNA is designed to make working with time series simple, productive, and fun.

Quickstart

Let's load and prepare the data.

import pandas as pd
from etna.datasets import TSDataset

# Read the data
df = pd.read_csv("examples/data/example_dataset.csv")

# Create a TSDataset
ts = TSDataset(df, freq="D")

# Choose a horizon
HORIZON = 14

# Make train/test split
train_ts, test_ts = ts.train_test_split(test_size=HORIZON)

Define transformations and model:

from etna.models import CatBoostMultiSegmentModel
from etna.transforms import DateFlagsTransform
from etna.transforms import DensityOutliersTransform
from etna.transforms import FourierTransform
from etna.transforms import LagTransform
from etna.transforms import LinearTrendTransform
from etna.transforms import MeanTransform
from etna.transforms import SegmentEncoderTransform
from etna.transforms import TimeSeriesImputerTransform
from etna.transforms import TrendTransform

# Prepare transforms
transforms = [
    DensityOutliersTransform(in_column="target", distance_coef=3.0),
    TimeSeriesImputerTransform(in_column="target", strategy="forward_fill"),
    LinearTrendTransform(in_column="target"),
    TrendTransform(in_column="target", out_column="trend"),
    LagTransform(in_column="target", lags=list(range(HORIZON, 122)), out_column="target_lag"),
    DateFlagsTransform(week_number_in_month=True, out_column="date_flag"),
    FourierTransform(period=360.25, order=6, out_column="fourier"),
    SegmentEncoderTransform(),
    MeanTransform(in_column=f"target_lag_{HORIZON}", window=12, seasonality=7),
    MeanTransform(in_column=f"target_lag_{HORIZON}", window=7),
]

# Prepare model
model = CatBoostMultiSegmentModel()

Fit Pipeline and make a prediction:

from etna.pipeline import Pipeline

# Create and fit the pipeline
pipeline = Pipeline(model=model, transforms=transforms, horizon=HORIZON)
pipeline.fit(train_ts)

# Make a forecast
forecast_ts = pipeline.forecast()

Let's plot the results:

from etna.analysis import plot_forecast

plot_forecast(forecast_ts=forecast_ts, test_ts=test_ts, train_ts=train_ts, n_train_samples=50)

Print the metric value across the segments:

from etna.metrics import SMAPE

metric = SMAPE()
metric_value = metric(y_true=test_ts, y_pred=forecast_ts)
metric_value
{'segment_a': 4.799114474387907, 'segment_b': 3.271014290441896, 'segment_c': 6.758606238307858, 'segment_d': 4.512871862697337}

Notebook with this example is available here.

Installation

ETNA is available on PyPI, so you can use pip to install it.

Install default version:

pip install --upgrade pip
pip install etna

The default version doesn't contain all the dependencies, because some of them are needed only for specific models, e.g. Prophet, PyTorch. Available user extensions are the following:

  • prophet: adds prophet model`,
  • torch: adds models based on neural nets,
  • wandb: adds wandb logger,
  • auto: adds AutoML functionality,
  • statsforecast: adds models from statsforecast,
  • classiciation: adds time series classification functionality,
  • chronos: adds Chronos-like pretrained models,
  • timesfm: adds TimesFM pretrained models.

Install extension:

pip install etna[extension-name]

Install all the extensions:

pip install etna[all]

There are also developer extensions. All the extensions are listed in pyproject.toml.

Without the appropriate extension you will get an ImportError trying to import the model that needs it. For example, etna.models.ProphetModel needs prophet extension and can't be used without it.

Also, the library, starting with version 3.0, can be installed on the Google Colab and Kaggle platforms. To do this, you can use any of the instructions above.

On Google Colab, don't forget to restart the environment after installing the library.

Configuration

ETNA supports configuration files. It means that library will check that all the specified packages are installed prior to script start and NOT during runtime.

To set up a configuration for your project you should create a .etna file at the project's root. To see the available options look at Settings. There is an example of configuration file.

Tutorials

We have also prepared a set of tutorials for an easy introduction:

Notebook Interactive launch
Get started Binder
Backtest Binder
EDA Binder
Regressors and exogenous data Binder
Deep learning models Binder
Ensembles Binder
Outliers Binder
AutoML Binder
Clustering Binder
Feature selection Binder
Forecasting strategies Binder
Mechanics of forecasting Binder
Embedding models Binder
Custom model and transform Binder
Inference: using saved pipeline on a new data Binder
Hierarchical time series Binder
Forecast interpretation Binder
Classification Binder
Prediction intervals Binder
Working with misaligned data Binder

Documentation

ETNA documentation is available here.

Community

Questions and feedback are welcome! Our channels for communication:

  • Discussions
    • Suggestions with ideas and drawbacks
    • Q&A, e.g. usage questions
    • General discussions
  • Issue tracker
    • Bug reports
    • Tasks
  • Telegram chat
    • Useful for any other form of communication

Resources

Acknowledgments

ETNA.Team

Current team members: Dmitriy Bunin, Aleksandr Chikov, Vladislav Denisov, Martin Gabdushev, Artem Makhin, Ivan Mitskovets, Albina Munirova, Ivan Nedosekov, Rodion Petrov, Maxim Zherelo, Yakov Malyshev, Egor Baturin, Mikhail Bolev, Danil Smorchkov,

Former team members: Andrey Alekseev, Nikita Barinov, Julia Shenshina, Sergey Kolesnikov, Yuriy Tarasyuk, Konstantin Vedernikov, Nikolai Romantsov, Sergei Zhuravlev, Alexandr Kuznetsov, Grigory Zlotin, Dmitriy Sablin, Artem Levashov, Aleksey Podkidyshev

ETNA.Contributors

GooseIt, mvakhmenin, looopka, aleksander43smith, smetam, Wapwolf, ArtemLiA, Carlosbogo, GoshaLetov, LeorFinkelberg, Pacman1984,

License

Feel free to use our library in your commercial and private applications.

ETNA is covered by Apache 2.0. Read more about this license here

Please note that etna[prophet] is covered by GPL 2.0 due to pystan package.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ts_etna-3.0.0.tar.gz (406.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ts_etna-3.0.0-py3-none-any.whl (570.6 kB view details)

Uploaded Python 3

File details

Details for the file ts_etna-3.0.0.tar.gz.

File metadata

  • Download URL: ts_etna-3.0.0.tar.gz
  • Upload date:
  • Size: 406.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.10 Linux/6.18.33.2-microsoft-standard-WSL2

File hashes

Hashes for ts_etna-3.0.0.tar.gz
Algorithm Hash digest
SHA256 c7fff095f9ce589a17c2309caa0945c9e66a9f53212285f41c8aa7015359d670
MD5 83795880dab79d10baa833482bb58a8d
BLAKE2b-256 59ac4c12d425c43a40b53c7733902350c3806b769f66c223c4b9ae4bd1a0257a

See more details on using hashes here.

File details

Details for the file ts_etna-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: ts_etna-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 570.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.10 Linux/6.18.33.2-microsoft-standard-WSL2

File hashes

Hashes for ts_etna-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1da5233d09f68f42287fc4050c41f9d2d4271080935f29f2f15b44614fcbd1df
MD5 857b867924b78e2d059f66628a49bf77
BLAKE2b-256 e5cfce01f3797a82c343583f1f6ba54d939192d35c0197da9b49045235390a40

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page