Skip to main content

toolset for time series forecasting

Project description

pypi license

(Docs)(Benchmark)

Introduction

tsts is an open-source easy-to-use toolset for time series forecasting.

What's New

Sep, 10

✨ New Model

Informer and related modules were added. See results for how to use it.

Installation

pip install tsts

Task Details

Time series forecasting is the task to predict the values of the time series on Horizon given the values of the time series on Lookback Period. Note that data can be multivariate.

Available Modules

Following modules are supported.

Architectures Losses Metrics Optimizers Scalers Schedulers
  • Informer
  • NBeats
  • Seq2Seq
  • DILATE
  • MAPE
  • MSE
  • MAE
  • MSE
  • RMSE
  • MAPE
  • Adam
  • SGD
  • MinMaxScaler
  • StandardScaler
  • CosineAnnealing
  • StepScheduler
  • Getting Started

    Following example shows how to train a model on sine curve dataset. See Docs for the details.

    Training

    Define config and start training with it.

    # cfg.yml
    LOGGER:
      # Log file and parameters are saved here
      LOG_DIR: "my-first-tsts-model"
    
    import torch
    from tsts.solvers import TimeSeriesForecaster
    
    # Define trainining + validation datasets (they are divided inside)
    sin_dataset = torch.sin(torch.arange(0.0, 100.0, 0.1))
    sin_dataset = sin_dataset.unsqueeze(-1)
    
    # Run training
    forecaster = TimeSeriesForecaster("cfg.yml")
    forecaster.fit([sin_dataset])
    

    See results in my-first-tsts-model directory.

    Inference

    For inference, it needs to load parameters from a log directory generated in training.

    import torch
    from tsts.scalers import StandardScaler
    from tsts.solvers import TimeSeriesForecaster
    
    # Initialize scaler with training dataset
    sin_dataset = torch.sin(torch.arange(0, 100, 0.1))
    sin_dataset = sin_dataset.unsqueeze(-1)
    X_scaler = StandardScaler()
    # NOTE: 0.75 is default training validation dataset ratio (training: 0.75, validation: 0.25)
    num_train_samples = int(0.75 * len(sin_dataset))
    X_scaler.fit(sin_dataset)
    
    # Define test dataset
    X = torch.sin(torch.arange(100.0, 110.0, 0.1))
    X = X.unsqueeze(-1)
    X = X_scaler.transform(X)
    
    # Run inference
    forecaster = TimeSeriesForecaster("cfg.yml")
    Z = forecaster.predict(X)
    
    # Initialize target to compare prediction with it
    y = torch.sin(torch.arange(110.0, 110.8, 0.1)).unsqueeze(1)
    y = X_scaler.transform(y)
    
    # Result
    print(Z)
    print(y)
    

    Examples

    See Benchmark for advanced usage.

    Project details


    Download files

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

    Source Distributions

    No source distribution files available for this release.See tutorial on generating distribution archives.

    Built Distribution

    tsts-0.4.0-py3-none-any.whl (50.7 kB view hashes)

    Uploaded Python 3

    Supported by

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