Learn R Programming

Metrics (version 0.1.4)

mape: Mean Absolute Percent Error

Description

mape computes the average absolute percent difference between two numeric vectors.

Usage

mape(actual, predicted)

Arguments

actual

The ground truth numeric vector.

predicted

The predicted numeric vector, where each element in the vector is a prediction for the corresponding element in actual.

Details

mape is calculated as the average of (actual - predicted) / abs(actual). This means that the function will return -Inf, Inf, or NaN if actual is zero. Due to the instability at or near zero, smape or mase are often used as alternatives.

See Also

mae smape mase

Examples

Run this code
# NOT RUN {
actual <- c(1.1, 1.9, 3.0, 4.4, 5.0, 5.6)
predicted <- c(0.9, 1.8, 2.5, 4.5, 5.0, 6.2)
mape(actual, predicted)
# }

Run the code above in your browser using DataLab