MAPE#

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

Bases: MultiHorizonMetric

Mean absolute percentage. Assumes y >= 0.

Defined as (y - y_pred).abs() / y.abs()

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

loss(y_pred, target)

Calculate loss without reduction.

loss(y_pred, target)[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