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.

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:
pip install -U tsururu

# For partial installation use corresponding option
# Extra dependencies: [catboost, torch] 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).

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.0.0.tar.gz (58.8 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.0.0-py3-none-any.whl (75.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tsururu-1.0.0.tar.gz
  • Upload date:
  • Size: 58.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Darwin/23.5.0

File hashes

Hashes for tsururu-1.0.0.tar.gz
Algorithm Hash digest
SHA256 af701175ea672bf1a8907a2333b67f7aa94132eb1fb13c3a22a07d3dd0903774
MD5 6043af175ecfea0fa23e8d156e0ada65
BLAKE2b-256 5dd60d3db3dc6e378b99afa0d756b8d5186079f61020915629f89cba88e7a0af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tsururu-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 75.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Darwin/23.5.0

File hashes

Hashes for tsururu-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b68e5680ba921310724677df14caf91f32a4f6b2aedaebf4a089fe8ecdd94f8
MD5 6ae329e27cee31506a88fdc30b832ce7
BLAKE2b-256 46d1accf690e1fd7323bd500d0bb1200965293ee85bd998d526baff570af43ab

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