Skip to content
EvalSuite
Documentation menu

Regression

Mean absolute percentage error

Implementedregression.mape

Definition

Average absolute error relative to the magnitude of the target.

Formula

MAPE = (1/N) Σᵢ |yᵢ − ŷᵢ| / |yᵢ|

Range: [0, ∞)

Inputs and outputs

  • y_true: array of real targets
  • y_pred: array of real predictions
  • sample_weight: optional

Returns: float

Assumptions

  • All targets must be non-zero; zero targets raise a validation error.

Limitations

  • Asymmetric: penalises over-prediction and under-prediction differently.

Python API

PythonSince v0.1.0
import evalsuite as es

es.mape(y_true_r, y_pred_r)

References

  1. Hyndman, R. J., & Koehler, A. B. (2006). Another look at measures of forecast accuracy. International Journal of Forecasting, 22(4), 679–688.

Implementation status