ape: Calculate absolute percent error between actual and forecast.

Description Usage Arguments Value Examples

View source: R/errors.R

Description

pe takes actual and forecast numeric vectors and returns a numeric vector where forecast is subtracted from the actual and then those errors are divided by the actuals. Lastly, the absolute value of those percent errors are taken.

Usage

1
ape(y_true = NULL, y_pred = NULL, actual = NULL, forecast = NULL)

Arguments

y_true

Ground truth (correct) target values.

y_pred

Estimated target values.

actual

a numeric vector of actuals.

forecast

a numeric vector of forecasts.

Value

a numeric vector of absolute percent errors.

Examples

1
2
# Examples
ape(1:100, 100:1)

Example output

  [1] 99.00000000 48.50000000 31.66666667 23.25000000 18.20000000 14.83333333
  [7] 12.42857143 10.62500000  9.22222222  8.10000000  7.18181818  6.41666667
 [13]  5.76923077  5.21428571  4.73333333  4.31250000  3.94117647  3.61111111
 [19]  3.31578947  3.05000000  2.80952381  2.59090909  2.39130435  2.20833333
 [25]  2.04000000  1.88461538  1.74074074  1.60714286  1.48275862  1.36666667
 [31]  1.25806452  1.15625000  1.06060606  0.97058824  0.88571429  0.80555556
 [37]  0.72972973  0.65789474  0.58974359  0.52500000  0.46341463  0.40476190
 [43]  0.34883721  0.29545455  0.24444444  0.19565217  0.14893617  0.10416667
 [49]  0.06122449  0.02000000  0.01960784  0.05769231  0.09433962  0.12962963
 [55]  0.16363636  0.19642857  0.22807018  0.25862069  0.28813559  0.31666667
 [61]  0.34426230  0.37096774  0.39682540  0.42187500  0.44615385  0.46969697
 [67]  0.49253731  0.51470588  0.53623188  0.55714286  0.57746479  0.59722222
 [73]  0.61643836  0.63513514  0.65333333  0.67105263  0.68831169  0.70512821
 [79]  0.72151899  0.73750000  0.75308642  0.76829268  0.78313253  0.79761905
 [85]  0.81176471  0.82558140  0.83908046  0.85227273  0.86516854  0.87777778
 [91]  0.89010989  0.90217391  0.91397849  0.92553191  0.93684211  0.94791667
 [97]  0.95876289  0.96938776  0.97979798  0.99000000
Warning messages:
1: In ape(1:100, 100:1) :
  'ape' is deprecated. Use 'absolute_percent_error' instead.
2: In pe(actual, forecast) :
  'pe' is deprecated. Use 'percent_error' instead.
3: In e(actual, forecast) :
  'e' is deprecated. Use 'absolute_error' instead.

scorer documentation built on May 2, 2019, 3:22 a.m.