Skip to main content

Python tool for time series forecasting

Project description

tsururu_logo

Tsururu (TSForesight) – a time series forecasting strategies framework

Tsururu is a Python-based library that provides a wide range of multi-series and multi-point-ahead prediction strategies, compatible with any underlying model, including neural networks.

While much attention is currently focused on selecting models for time series forecasting, the crucial aspect of how to perform training and inference often goes overlooked. Tsururu aims to address this gap.

Also tsururu provides various preprocessing techniques.

🎉 Accepted to the Demo-Track of IJCAI 2025 — Results and code can be found in examples.

Quick tour

from tsururu.dataset import Pipeline, TSDataset
from tsururu.model_training.trainer import MLTrainer
from tsururu.model_training.validator import KFoldCrossValidator
from tsururu.models.boost import CatBoost
from tsururu.strategies import RecursiveStrategy

dataset_params = {
    "target": {"columns": ["value"]},
    "date": {"columns": ["date"]},
    "id": {"columns": ["id"]},
}

dataset = TSDataset(
    data=pd.read_csv(df_path),
    columns_params=dataset_params,
)

pipeline = Pipeline.easy_setup(
    dataset_params, {"target_lags": 3, "date_lags": 1}, multivariate=False
)
trainer = MLTrainer(model=CatBoost, validator=KFoldCrossValidator)
strategy = RecursiveStrategy(horizon=3, history=7, trainer=trainer, pipeline=pipeline)

fit_time, _ = strategy.fit(dataset)
forecast_time, current_pred = strategy.predict(dataset)

Installation

To install Tsururu on your machine from PyPI:

# Base functionality (it's recommended to install at least one addition dependency with models):
pip install -U tsururu

# For partial installation use corresponding option
# Extra dependencies: [catboost, torch, pyboost] or use 'all' to install all dependencies
pip install -U tsururu[catboost]

Other tutorials and examples

Multi-series prediction strategies:

  • Local-modelling:
    • An individual model for each time series.
    • Each time series is modeled independently of the others.
  • Global-modelling:
    • A single model for all time series.
    • Features created from each series do not overlap with other series. Series are related but modeled separately.
  • Multivariate-modelling:
    • A single model for all time series.
    • Features created from each series are concatenated at each time step. Try to capture dependencies between the series at the same time point.

Multi-point-ahead prediction strategies:

  • Recursive:
    • One model is used for the entire forecast horizon.
    • training: The model is trained to predict one point ahead.
    • prediction: The model iteratively predicts each point, using previous predictions to update the features in the test data.
    • Note 1: There is an option to use a “reduced” version, where features are generated for all test observations at once, and unavailable values are filled with NaN.
    • Note 2: Recursive can also be combined with the MIMO strategy, allowing the model to predict model_horizon points ahead at each step.
  • Direct:
    • Individual models are trained for each point in the forecast horizon.
    • Note 1: There is an option to use "equal_train_size" option, where all models can be trained on the same X_train set, formed for the last model predicting h point. Only the target variable (y) is updated for each model, reducing the time spent generating new training sets.
    • Note 2: Direct can also be combined with MIMO, where each individual model predicts model_horizon points ahead.
  • MultiOutput (MIMO - Multi-input-multi-output):
    • One model is trained and used for the entire forecast horizon at once.
    • Note 1: This strategy can also accommodate exogenous features (for local- or global-modelling strategies).
  • FlatWideMIMO:.
    • A hybrid of Direct and MIMO. One model is trained, but Direct’s features are deployed across the forecast horizon.
    • Note 1: To use FlatWideMIMO with date-related features, h lags of them must be included (with help of LagTransformer).

Models:

Preprocessing

  • StandardScalerTransformer: scales features to have zero mean and unit variance.
  • DifferenceNormalizer: transforms features by subtracting or dividing by their previous value.
  • TimeToNumGenerator and DateSeasonsGenerator: generates seasonal features (e.g., month, quarter, day of the week) from date information.
  • LabelEncodingTransformer and OneHotEncodingTransformer: encodes categorical features.
  • MissingValuesImputer: handles missing values by imputing them with a chosen strategy.
  • LagTransformer: generates lagged features.
  • LastKnownNormalizer: normalizes lagged features by the last known value in history, either by subtracting it or dividing by it.

License

This project is licensed under the Apache License, Version 2.0. See LICENSE file for more details.

Back to top

Project details


Download files

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

Source Distribution

tsururu-1.1.0.tar.gz (69.1 kB view details)

Uploaded Source

Built Distribution

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

tsururu-1.1.0-py3-none-any.whl (90.2 kB view details)

Uploaded Python 3

File details

Details for the file tsururu-1.1.0.tar.gz.

File metadata

  • Download URL: tsururu-1.1.0.tar.gz
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tsururu-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1b8b7c81d729a6951cff12126ffdc4f5b387faababf8b3241de7c43a29780636
MD5 6af83de682c010a0790c8e1335313e42
BLAKE2b-256 bc4705150ba747cf58d45ea7378ec80d80b07506895cebce6ffc1faf0475aa86

See more details on using hashes here.

File details

Details for the file tsururu-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tsururu-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 90.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tsururu-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f65379d33cebb4c0cafefec51513961d32067f80b1afbeb0aa2280d870a0239
MD5 e3e7176b798f88b590892bc9c2fdb217
BLAKE2b-256 67735eaee8c12fd5dca45d45a4d182fb5407e2a961c2f11d224550c7bfc16118

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page