timesead.data.dataset

Classes

BaseTSDataset

Base class for all time-series datasets in TimeSeAD. Implementing the members in this abstract class provides the

Functions

collate_fn(→ Callable)

Puts each data field into a tensor with outer dimension batch size.

Module Contents

class timesead.data.dataset.BaseTSDataset

Bases: abc.ABC, torch.utils.data.Dataset

Base class for all time-series datasets in TimeSeAD. Implementing the members in this abstract class provides the data pipeline system with the necessary information to process the data correctly.

abstract __len__() int

This should return the number of independent time series in the dataset

Return type:

int

property seq_len: int | List[int]
Abstractmethod:

Return type:

Union[int, List[int]]

This should return the length of each time series. If the time series have different lengths, the return value should be a list that contains the length of each sequence. If all sequences are of equal length, this should return an int.

property num_features: int | Tuple[int, Ellipsis]
Abstractmethod:

Return type:

Union[int, Tuple[int, Ellipsis]]

Number of features of each datapoint. This can also be a tuple if the data has more than one feature dimension.

static get_default_pipeline() Dict[str, Dict[str, Any]]
Abstractmethod:

Return type:

Dict[str, Dict[str, Any]]

Return the default pipeline for this dataset that is used if the user does not specify a different pipeline. This must be a dict of the form:

{
    '<name>': {'class': '<name-of-transform-class>', 'args': {'<args-for-constructor>', ...}},
    ...
}
static get_feature_names() List[str]
Abstractmethod:

Return type:

List[str]

Return names for the features in the order they are present in the data tensors.

Returns:

A list of strings with names for each feature.

Return type:

List[str]

abstract __getitem__(index: int) Tuple[Tuple[torch.Tensor, Ellipsis], Tuple[torch.Tensor, Ellipsis]]

Access the timeseries at position index and its corresponding label sequence. A call to this function should return a single time series that was sampled independently of the other time series in this dataset.

Parameters:

index (int) – The zero-based index of the time series to retrieve.

Returns:

A tuple (inputs, targets), where inputs is again a tuple of Tensors with shape (T, D*), where D* can very between the tensors. targets contains labels for the time series as tensors of shape (T,).

Return type:

Tuple[Tuple[torch.Tensor, Ellipsis], Tuple[torch.Tensor, Ellipsis]]

timesead.data.dataset.collate_fn(batch_dim: int) Callable

Puts each data field into a tensor with outer dimension batch size.

This was largely copied from PyTorch’s default_collate() function except that it allows concatenating Tensors along an arbitrary dimension instead of always stacking along the first dimension.

Parameters:

batch_dim (int) – The index of the dimension along which to stack the elements in the batch.

Returns:

Batched tensors where elements have been stacked along the batch_dim dimension.

Return type:

Callable