Merge pull request #38 from felipenv/master

- fix rmse: aligned targets and forecasts for calculation
This commit is contained in:
Petrônio Cândido de Lima e Silva 2021-02-23 10:40:53 -03:00 committed by GitHub
commit e536b0d8eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ def acf(data, k):
return 1 / ((n - k) * sigma) * s return 1 / ((n - k) * sigma) * s
def rmse(targets, forecasts): def rmse(targets, forecasts, order, steps_ahead):
""" """
Root Mean Squared Error Root Mean Squared Error
@ -41,9 +41,15 @@ def rmse(targets, forecasts):
targets = np.array(targets) targets = np.array(targets)
if isinstance(forecasts, list): if isinstance(forecasts, list):
forecasts = np.array(forecasts) forecasts = np.array(forecasts)
return np.sqrt(np.nanmean((targets - forecasts) ** 2)) return np.sqrt(np.nanmean((targets[order+steps_ahead:] - forecasts[:-steps_ahead]) ** 2))
def nmrse(targets, forecasts, order, steps_ahead):
""" Normalized Root Mean Squared Error """
return rmse(targets, forecasts, order, steps_ahead) / (np.max(targets) - np.min(targets)) ## normalizing in targets because on forecasts might explode to inf (when model predict a line)
def rmse_interval(targets, forecasts): def rmse_interval(targets, forecasts):
""" """
Root Mean Squared Error Root Mean Squared Error