-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy patherrorMetrics.py
More file actions
55 lines (43 loc) · 2.03 KB
/
Copy patherrorMetrics.py
File metadata and controls
55 lines (43 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ----------------------------------------------------------------------
# Copyright (c) 2017, Jin-Man Park. All rights reserved.
# Contributors: Jin-Man Park and Jong-hwan Kim
# Affiliation: Robot Intelligence Technology Lab.(RITL), Korea Advanced Institute of Science and Technology (KAIST)
# URL: http://rit.kaist.ac.kr
# E-mail: jmpark@rit.kaist.ac.kr
# Citation: Jin-Man Park, and Jong-Hwan Kim. "Online recurrent extreme learning machine and its application to
# time-series prediction." Neural Networks (IJCNN), 2017 International Joint Conference on. IEEE, 2017.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero Public License version 3 as
# published by the Free Software Foundation.
# ----------------------------------------------------------------------
# This code is originally from Numenta's Hierarchical Temporal Memory (HTM) code
# (Numenta Platform for Intelligent Computing (NuPIC))
# And modified to run Online Recurrent Extreme Learning Machine (OR-ELM)
# ----------------------------------------------------------------------
import numpy as np
def NRMSE(data, pred):
return np.sqrt(np.nanmean(np.square(pred-data)))/\
np.nanstd(data)
def NRMSE_sliding(data, pred, windowSize):
"""
Computing NRMSE in a sliding window
:param data:
:param pred:
:param windowSize:
:return: (window_center, NRMSE)
"""
halfWindowSize = int(round(float(windowSize)/2))
window_center = range(halfWindowSize, len(data)-halfWindowSize, int(round(float(halfWindowSize)/5.0)))
nrmse = []
for wc in window_center:
nrmse.append(NRMSE(data[wc-halfWindowSize:wc+halfWindowSize],
pred[wc-halfWindowSize:wc+halfWindowSize]))
return (window_center, nrmse)
def altMAPE(groundTruth, prediction):
error = abs(groundTruth - prediction)
altMAPE = 100.0 * np.sum(error) / np.sum(abs(groundTruth))
return altMAPE
def MAPE(groundTruth, prediction):
MAPE = np.nanmean(
np.abs(groundTruth - prediction)) / np.nanmean(np.abs(groundTruth))
return MAPE