commonpower.data_forecasting.nn_forecasting.dataset_wrappers.NStepAhead

class NStepAhead(data_source: ~commonpower.data_forecasting.base.DataSource, data_split: ~commonpower.data_forecasting.nn_forecasting.data_splitting.DatasetSplit, model: ~commonpower.data_forecasting.nn_forecasting.models.NNModule, targets: list[str], features: list[str], feature_transform: ~commonpower.data_forecasting.nn_forecasting.transform.Transformation = <commonpower.data_forecasting.nn_forecasting.transform.IdentityTransform object>, target_transform: ~commonpower.data_forecasting.nn_forecasting.transform.Transformation = <commonpower.data_forecasting.nn_forecasting.transform.IdentityTransform object>)[source]

Bases: DatasetWrapper

The NStepAhead wrapper inspects the passed model instance and determines the look back and steps ahead values from the model input and output shapes. The dataset is then constructed such that each data point has input dimension (n_look_back, n_features) and target dimension (n_steps_ahead, n_targets).

Parameters:
  • data_source (DataSource) – The data source for the dataset.

  • data_split (DatasetSplit) – The split of the dataset.

  • model (NNModule) – The neural network model.

  • targets (list[str]) – The list of target variables.

  • features (list[str]) – The list of feature variables.

  • feature_transform (Transformation, optional) – The transformation to apply to the features. Defaults to IdentityTransform().

  • target_transform (Transformation, optional) – The transformation to apply to the targets. Defaults to IdentityTransform().

Returns:

NStepAhead – The initialized NStepAhead object.

Methods

_get_item(idx: int) tuple[Tensor, Tensor][source]

Returns the data point at the given index.

Parameters:

idx (int) – Index of the data point.

Returns:

tuple[torch.Tensor, torch.Tensor] – (input, target)