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 --directory docs/build/html).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsloader-3.1.0.tar.gz.
File metadata
- Download URL: tsloader-3.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de9568dc32e7735142e7e7bd512d18c14dbbb47dfaec4c30dbda0510b153660b
|
|
| MD5 |
0034137596c82a295248c07778f77ea4
|
|
| BLAKE2b-256 |
c5efeee25753d1906d1a6f15122171c82298c1f5220b1699b6ee1c4a737ff2f0
|
File details
Details for the file tsloader-3.1.0-py3-none-any.whl.
File metadata
- Download URL: tsloader-3.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b2edb32cc8c2b35d6e81e30660170aeab335074c4aa54faeaaa863fdd5c11ab
|
|
| MD5 |
f68ed5416ef1dd43233759756a6bac56
|
|
| BLAKE2b-256 |
245c664a74e8c7468d7e9f2f1155c235266cfffb233ac840a468c09f2d64e7d9
|