Forecasting Metrics.
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __total_error(ts=ts, f=f) == 1.
ts, f = np.array([1, 2, 3, np.nan]), np.array([.5, 2.5, 2, 1])
assert __total_error(ts=ts, f=f) == 1
df, _ = moving_average.SMA(
1,
df=simulate_data.pandas_time_series(),
)
__total_error(ts= df['time_series'].to_numpy(), f=df['ma_1'].to_numpy())
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __absolute_error(ts=ts, f=f) == 2
ts, f = np.array([np.nan, 1, 2, 3]), np.array([100, .5, 2.5, 2])
assert __absolute_error(ts=ts, f=f) == 2
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __squared_error(ts=ts, f=f) == 2 * (.5)**2 + 1
ts, f = np.array([1, 2, np.nan, 3]), np.array([.5, 2.5, 10**3, 2])
assert __squared_error(ts=ts, f=f) == 2 * (.5)**2 + 1
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __mean_error(ts=ts, f=f) == (1 / 3) * (1)
ts, f = np.array([1, 2, 10**3, 3]), np.array([.5, 2.5, np.nan, 2])
assert __mean_error(ts=ts, f=f) == (1 / 3) * (1)
ts, f = np.array([np.nan, np.nan]), np.array([.5, 2.5])
assert abs(__mean_error(ts=ts, f=f)) < 10**(-20)
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __mean_absolute_error(ts=ts, f=f) == (1 / 3)*(2)
ts, f = np.array([np.nan, np.nan]), np.array([.5, 2.5])
assert abs(__mean_absolute_error(ts=ts, f=f)) < 10**(-20)
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __mean_squared_error(ts=ts, f=f) == (1 / 3) * (2 * .5**2 + 1)
ts, f = np.array([np.nan, np.nan]), np.array([.5, 2.5])
assert __mean_squared_error(ts=ts, f=f) < 10**(-20)
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __root_mean_square_error(ts=ts, f=f) == np.sqrt((1 / 3) * (2 * .5**2 + 1))
ts, f = np.array([np.nan, np.nan]), np.array([.5, 2.5])
assert __root_mean_square_error(ts=ts, f=f) < 10**(-20)
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __mean_percentage_error(ts=ts, f=f) == (.5 / 2 + 1 / 3) * (1 / 3)
ts, f = np.array([np.nan, np.nan]), np.array([.5, 2.5])
assert __mean_percentage_error(ts=ts, f=f) < 10**(-20)
ts, f = np.array([1, 2, 3]), np.array([.5, 2.5, 2])
assert __mean_absolute_percent_error(ts=ts,
f=f) == np.divide(.5 * (3. / 2) + (1. / 3),
3)
ts, f = np.array([np.nan, np.nan]), np.array([.5, 2.5])
assert __mean_percentage_error(ts=ts, f=f) < 10**(-20)
SUMMARY()