Saltar al contenido principal

MAPE

Metric
DashAI.back.metrics.forecasting.MAPE

Average error as a percentage of the true value.

Mean Absolute Percentage Error expresses each error relative to the value it missed, so a forecast can be judged without knowing the scale of the series. That is what makes it the usual way to compare a forecast across products, regions or periods whose magnitudes differ by orders of magnitude, where an absolute error in units says nothing on its own.

::

MAPE(y, y') = 100 / N · sum |yi - y'i| / |yi|

Range: [0, +inf), lower is better.

The formula divides by the true value, so it is undefined wherever that value is zero. Those rows are left out of the average rather than being allowed to produce an infinity that would swallow the whole score, and a series that is zero throughout has no defined MAPE at all, which is reported as nan. Prefer :class:SMAPE on series that reach zero.

MAPE is also asymmetric: it penalises a forecast that is too high more heavily than one that is too low by the same amount, since the denominator stays fixed while the error does not.

References

Methods

score(true_values: 'DashAIDataset', pred_values: 'np.ndarray') -> float

Defined on MAPE

Calculate the MAPE between true values and predicted values.

Parameters

true_values : DashAIDataset
A DashAI dataset with true values.
pred_values : np.ndarray
A one-dimensional array with the predicted values for each instance.

Returns

float
MAPE as a percentage. nan when every true value is zero, since no row of such a series has a defined percentage error.

get_metadata(cls: 'BaseMetric') -> Dict[str, Any]

Defined on BaseMetric

Get metadata values for the current metric.

Returns

Dict[str, Any]
Dictionary with the metadata

Compatible with