tsts.models

Functions

class tsts.models.build_model[source]

Build model.

Parameters
  • num_in_feats (int) – Number of input features

  • num_out_feats (int) – Number of output features

  • cfg (CN) – Global configuration

Returns

Forecasting model

Return type

Module

Classes

class tsts.models.Informer[source]

Informer implementation.

Example

Add following section to use Informer.

MODEL:
  NAME: "Informer"
  NUM_H_UNITS: 512
Parameters
  • num_in_feats (int) – Number of input features

  • num_out_feats (int) – Number of output features

  • lookback (int) – Number of input time steps

  • horizon (int. optional) – Indicate how many steps it predicts by default 1

  • num_h_feats (int, optional) – Number of hidden features, by default 512

  • num_encoders (int, optional) – Number of encoders, by default 2

  • num_decoders (int, optional) – Number of decoders, by default 1

  • num_heads (int, optional) – Number of heads of multi-head self attention, by default 8

  • contraction_factor (int, optional) – Factor which detemines the number of samples of queries and keys in ProbSparseSelfAttention, by default 5

  • dropout_rate (int, optional) – Dropout rate, by default 0.05

  • expansion_rate (int, optional) – Expansion rate which determines the number of filters in conv layers after attention, by default 4.0

  • distil (bool, optional) – Flag if use distillation module after each encoder except the last one, by default True

  • dec_in_size (int, optional) – Size of input to decoder (last dec_in_size values of input to encoder are used), by default 24

  • add_last_step_val (bool, optional) – If True, Add x_t (the last value of input time series) to every output, by default False

forward(X: torch.Tensor, bias: torch.Tensor, X_mask: torch.Tensor, time_stamps: List[Optional[torch.Tensor]]) torch.Tensor[source]

Return prediction.

Parameters
  • X (Tensor) – Input time series

  • X_mask (Tensor) – Input time series mask

Returns

Prediction

Return type

Tensor

class tsts.models.NBeats[source]

N-Beats implementation.

Example

Add following section to use NBeats.

MODEL:
  NAME: "NBeats"
  NUM_H_UNITS: 512
  NUM_STACKS: 30
Parameters
  • num_in_feats (int) – Number of input features

  • num_out_feats (int) – Number of output features

  • lookback (int) – Number of input time steps

  • horizon (int. optional) – Indicate how many steps it predicts by default 1

  • num_h_units (int) – Number of hidden units

  • depth (int) – Number of hidden layers per block

  • stack_size (int) – Number of blocks

  • add_last_step_val (bool, optional) – If True, Add x_t (the last value of input time series) to every output, by default True

forward(X: torch.Tensor, bias: torch.Tensor, X_mask: torch.Tensor, time_stamps: Optional[torch.Tensor] = None) torch.Tensor[source]

Return prediction.

Parameters
  • X (Tensor) – Input time series

  • X_mask (Tensor) – Input time series mask

Returns

Prediction

Return type

Tensor

class tsts.models.Seq2Seq[source]

Seq2Seq implementation.

Example

Add following section to use Seq2Seq.

MODEL:
  NAME: "Seq2Seq"
  NUM_H_UNITS: 64
Parameters
  • num_in_feats (int) – Number of input features

  • num_out_feats (int) – Number of output features

  • horizon (int. optional) – Indicate how many steps it predicts by default 1

  • num_h_units (int, optional) – Number of hidden units, by default 64

  • depth (int, optional) – Number of hidden layers, bu default 2

  • add_last_step_val (bool, optional) – If True, Add x_t (the last value of input time series) to every output, by default False

forward(X: torch.Tensor, bias: torch.Tensor, X_mask: torch.Tensor, time_stamps: Optional[torch.Tensor] = None) torch.Tensor[source]

Return prediction.

Parameters
  • X (Tensor) – Input time series

  • X_mask (Tensor) – Input time series mask

Returns

Prediction

Return type

Tensor