-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigs.py
110 lines (85 loc) · 3.06 KB
/
configs.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import tensorflow as tf
from tensorflow.keras import backend as K
# univariate time series forecasting
class BJPMConfig:
def __init__(self):
self.train_rate = 0.6
self.valid_rate = 0.2
self.window = 24*7
self.horizon = 1
self.T = 43824
self.D = 8
self.K = 1
self.metrics = [tf.keras.metrics.MeanAbsoluteError()]
self.lr = 0.001
class GefComPriceConfig:
def __init__(self):
self.train_rate = 0.6
self.valid_rate = 0.2
self.window = 24
self.horizon = 1
self.T = 21552
self.D = 9
self.K = 1
self.metrics = [tf.keras.metrics.MeanAbsoluteError()]
self.lr = 0.001
# multivariate time series forecasting
#Electricity | EXchange_Rate | Solar_Energy | Traffic
class ElectricityConfig:
def __init__(self):
self.train_rate = 0.6
self.valid_rate = 0.2
self.window = 24*7
self.horizon = 24
self.normalize = 2
self.T = 26304
self.D = 321
self.K = 321
self.metrics = [rse, corr]
self.lr = 0.001
class EXchange_RateConfig:
def __init__(self):
self.train_rate = 0.6
self.valid_rate = 0.2
self.window = 24*7
self.horizon = 24
self.normalize = 2
self.T = 7588
self.D = 8
self.K = 8
self.metrics = [rse, corr]
self.lr = 0.001
class Solar_EnergyConfig:
def __init__(self):
self.train_rate = 0.6
self.valid_rate = 0.2
self.window = 24*7
self.horizon = 24
self.normalize = 2
self.T = 52560
self.D = 137
self.K = 137
self.metrics = [rse, corr]
self.lr = 0.001
class TrafficConfig:
def __init__(self):
self.train_rate = 0.6
self.valid_rate = 0.2
self.window = 24*7
self.horizon = 24
self.normalize = 2
self.T = 17544
self.D = 862
self.K = 862
self.metrics = [rse, corr]
self.lr = 0.001
def rse(y_true, y_pred, epsilon=1e-8):
num = K.sqrt(K.sum(K.square(y_true - y_pred)))
den = K.sqrt(K.sum(K.square(y_true - K.mean(y_true))))
return num / (den+epsilon)
def corr(y_true, y_pred, epsilon=1e-8):
num1 = y_true - K.mean(y_true, axis=0)
num2 = y_pred - K.mean(y_pred, axis=0)
num = K.mean(num1 * num2, axis=0)
den = K.std(y_true, axis=0) * K.std(y_pred, axis=0)
return K.mean(num / (den+epsilon))