Skip to content

Commit

Permalink
Merge pull request #38 from felipenv/master
Browse files Browse the repository at this point in the history
- fix rmse: aligned targets and forecasts for calculation
  • Loading branch information
petroniocandido committed Feb 23, 2021
2 parents acd007d + d5c4482 commit e536b0d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pyFTS/benchmarks/Measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def acf(data, k):
return 1 / ((n - k) * sigma) * s


def rmse(targets, forecasts):
def rmse(targets, forecasts, order, steps_ahead):
"""
Root Mean Squared Error
Expand All @@ -41,9 +41,15 @@ def rmse(targets, forecasts):
targets = np.array(targets)
if isinstance(forecasts, list):
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):
"""
Root Mean Squared Error
Expand Down

0 comments on commit e536b0d

Please sign in to comment.