MASE#

class pytorch_forecasting.metrics.point.MASE(reduction: str = 'mean', **kwargs)[source]#

Bases: MultiHorizonMetric

Mean absolute scaled error

Defined as (y_pred - target).abs() / all_targets[:, :-1] - all_targets[:, 1:]).mean(1). all_targets are here the concatenated encoder and decoder targets

Initialize metric

Parameters
  • name (str) – metric name. Defaults to class name.

  • quantiles (List[float], optional) – quantiles for probability range. Defaults to None.

  • reduction (str, optional) – Reduction, “none”, “mean” or “sqrt-mean”. Defaults to “mean”.

Methods

calculate_scaling(target, lengths, ...)

loss(y_pred, target, scaling)

Calculate loss without reduction.

update(y_pred, target, encoder_target[, ...])

Update metric that handles masking of values.

loss(y_pred, target, scaling)[source]#

Calculate loss without reduction. Override in derived classes

Parameters
  • y_pred – network output

  • y_actual – actual values

Returns

loss/metric as a single number for backpropagation

Return type

torch.Tensor

update(y_pred, target, encoder_target, encoder_lengths=None) Tensor[source]#

Update metric that handles masking of values.

Parameters
  • y_pred (Dict[str, torch.Tensor]) – network output

  • target (Tuple[Union[torch.Tensor, rnn.PackedSequence], torch.Tensor]) – tuple of actual values and weights

  • encoder_target (Union[torch.Tensor, rnn.PackedSequence]) – historic actual values

  • encoder_lengths (torch.Tensor) – optional encoder lengths, not necessary if encoder_target is rnn.PackedSequence. Assumed encoder_target is torch.Tensor

Returns

loss as a single number for backpropagation

Return type

torch.Tensor