toolset for time series forecasting
Project description
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 |
|
|
|
|
|
|
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 training + 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
from tsts.utils import plot
# Initialize scaler with training dataset
sin_dataset = torch.sin(torch.arange(0.0, 100.0, 0.1))
sin_dataset = sin_dataset.unsqueeze(-1)
# NOTE: 0.75 is default training validation dataset ratio (training: 0.75, validation: 0.25)
num_train_samples = int(0.75 * len(sin_dataset))
sin_dataset = sin_dataset[:num_train_samples]
X_scaler = StandardScaler()
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, 114.8, 0.1)).unsqueeze(1)
y = X_scaler.transform(y)
# Result
plot(Z, y, xticks=torch.arange(110.0, 114.8, 0.1))
Result:
Examples
See Benchmark for advanced usage.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.