Go to file
max-accenta 3018014e08 Oups 2024-10-28 14:30:34 +00:00
docs Switch docs theme to furo 2024-01-30 16:49:28 +01:00
examples Rename package to "tsloader" 2023-08-05 10:09:24 +02:00
tests Fix some depreciations from pandas 2.2 2024-01-30 17:18:06 +01:00
tsloader Bump to 3.1.0 2024-01-30 17:31:42 +01:00
.dockerignore Add Dockerfile running tests 2023-08-16 10:39:24 +02:00
.gitignore Add coverage to gitignore 2024-01-30 16:36:09 +01:00
CHANGELOG.md Bump to 3.1.0 2024-01-30 17:31:42 +01:00
Dockerfile Update Dockerfile to use cache and requirements.txt file 2024-01-30 17:24:07 +01:00
LICENSE Oups 2024-10-28 14:30:34 +00:00
README.md Switch docs architecture to build/source 2024-01-30 16:45:44 +01:00
pyproject.toml Bump minimal python version to 3.9.17 2024-01-30 17:16:54 +01:00
requirements-dev.txt Add black to dev requirements 2023-08-05 10:38:49 +02:00
requirements.txt Fix some depreciations from pandas 2.2 2024-01-30 17:18:06 +01:00

README.md

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 --directory docs/build/html).