-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
75 lines (61 loc) · 1.41 KB
/
index.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var exports = module.exports={};
// Mean Forecast Error
exports.mfe = function(a,b){
let error = 0;
for (let i = 0; i < a.length; i++) {
error += (a[i] - b[i])
}
return error / a.length
}
// Mean Squared Error
exports.mse = function(a, b) {
let error = 0
for (let i = 0; i < a.length; i++) {
error += Math.pow((b[i] - a[i]), 2)
}
return error / a.length
}
// Root Mean Squared Error
exports.rmse = function(a,b){
let error = 0
for (let i = 0; i < a.length; i++) {
error += Math.pow((b[i] - a[i]), 2)
}
error = Math.sqrt(error/a.length)
return error
}
exports.mae = function(a,b){
let error = 0
for (let i = 0; i < a.length; i++) {
error += Math.abs(a[i] - b[i])
}
return error
}
exports.mase =function(a,b){
let error = 0
for (let i = 0; i < a.length; i++) {
error += Math.abs(a[i] - b[i])
}
mae_error_naive = error/(a.length - 1)
mae_error_algo = error/(a.length)
mase = (mae_error_algo/mae_error_naive)
return mase
}
exports.mape = function(a,b){
let error = 0
for (let i = 0; i < a.length; i++) {
error += (Math.abs(a[i] - b[i])/a[i])
}
mape = error/a.length
return this.mape;
}
exports.smape = function(a,b){
let error = 0
for (let i = 0; i < a.length; i++) {
error += (Math.abs(a[i] - b[i]))/((a[i] + b[i])/2)
}
smape = error/a.length
return this.smape;
}
a = [1.0, 2.9, 2.8]
b = [-19.8, -18.2, -10.11]