Skip to main content

Load time series in pyTorch dataloaders.

Project description

Time Series Loader

Manage time series dataset to be served as torch dataloaders. The main features are:

  • Load a csv file into dataloaders
  • Handle train/val/test splits
  • Normalize and rescale each variable

Example usage

We first build a PyTorch Dataset, then a pytorch-lightning DataModule.

from tsloader import TimeSeriesDataset, TimeSeriesDataModule

class ETDataset(TimeSeriesDataset):
    columns_inputs = ["HUFL", "HULL", "MUFL", "MULL", "LUFL", "LULL"]
    columns_targets = ["OT"]

    train_start = datetime.datetime(year=2016, month=7, day=1)
    train_end = validation_start = datetime.datetime(year=2017, month=7, day=1)
    validation_end = test_start = validation_start + datetime.timedelta(days=28 * 4)
    test_end = test_start + datetime.timedelta(days=28 * 4)
    stride_size = 24

    def preprocess(self):
        self.df["datetime"] = self.df["date"].apply(pd.to_datetime)


class ETDataModule(TimeSeriesDataModule):
    Dataset = ETDataset


# Setup the datamodule
datamodule = ETDataModule(
    dataset_path="datasets/ett/ETTh1.csv", forecast_size=48, batch_size=4
)
datamodule.setup()
# Visualize the entire dataset
datamodule.visualize()
# Load a sample from the training dataloader
dataloader = datamodule.train_dataloader()
for commands, observations in dataloader:
    ...

Installation

Using pip, we can simply install the latest release. The main branch is considered stable.

$ pip install git+https://git.zagouri.org/max/tsloader

If you are from Accenta, then you probably want to install the Accenta-specific version of this package:

$ pip install git+https://git.zagouri.org/max-accenta/tsloader

Compiling the documentation

The required libraries for compiling the documentation are listed in docs/requirements.txt. Once installed, run the following command from the docs/ folder:

$ make html

The documentation is built to the folder docs/_build/html/, and can be viewed by moving inside the directory and launching a temporary http server (for instance python -m http.server).

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

tsloader-3.0.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

tsloader-3.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file tsloader-3.0.1.tar.gz.

File metadata

  • Download URL: tsloader-3.0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for tsloader-3.0.1.tar.gz
Algorithm Hash digest
SHA256 67eca525635870f4f3c2b9d69db8738938a3546d26dcce32b3f7bfdcaf4a018d
MD5 0e567ff33ab8a73acf0bc127b42e51f8
BLAKE2b-256 dbe30396ad2f338c5d9364aae22778cc3ef88a8375cf7f1dd2216d4faca1fe5d

See more details on using hashes here.

File details

Details for the file tsloader-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: tsloader-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for tsloader-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 adc6cf9e6dc64d941d0bf0af211c385a5f5ecc110f8c16603227b94eb14b3abf
MD5 b3212985a5073c57ad9a3f110693f748
BLAKE2b-256 0b9621c8f53f1e81cc341d618a9a85edd611800466d70e9a2cbc16fc1ee4c41e

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