Building a DataModule class for TSC
In this recipe, we return to the PyTorch Lightning framework. We’ll build a DataModule
class to encapsulate the data preprocessing and the passing of observations to models.
Getting ready
Let’s load the dataset from the previous recipe:
import pandas as pd data_directory = 'assets/datasets/Car' train = pd.read_table(f'{data_directory}/Car_TRAIN.tsv', header=None) test = pd.read_table(f'{data_directory}/Car_TEST.tsv', header=None)
Next, we’ll build a DataModule
class to handle this dataset.
How to do it…
In the previous chapters, we used TimeSeriesDataSet
from PyTorch Forecasting to handle the data preparation for us. This class managed several steps. These include normalization and transformation of the data for supervised learning. However, in TSC, an observation uses the entire time series as input:
- We’ll start creating a simpler variant of
TimeSeriesDataSet...