def create_dataset(self, len_closeness=3, len_trend=3, TrendInterval=7, len_period=3, PeriodInterval=1):
"""current version
"""
# offset_week = pd.DateOffset(days=7)
offset_frame = pd.DateOffset(minutes=24 * 60 // self.T)
XC = []
XP = []
XT = []
Y = []
timestamps_Y = []
depends = [range(1, len_closeness+1),
[PeriodInterval * self.T * j for j in range(1, len_period+1)],
[TrendInterval * self.T * j for j in range(1, len_trend+1)]]
i = max(self.T * TrendInterval * len_trend, self.T * PeriodInterval * len_period, len_closeness)
while i < len(self.pd_timestamps):
Flag = True
for depend in depends:
if Flag is False:
break
Flag = self.check_it([self.pd_timestamps[i] - j * offset_frame for j in depend])
if Flag is False:
i += 1
continue
x_c = [self.get_matrix(self.pd_timestamps[i] - j * offset_frame) for j in depends[0]]
x_p = [self.get_matrix(self.pd_timestamps[i] - j * offset_frame) for j in depends[1]]
x_t = [self.get_matrix(self.pd_timestamps[i] - j * offset_frame) for j in depends[2]]
y = self.get_matrix(self.pd_timestamps[i])
if len_closeness > 0:
XC.append(np.vstack(x_c))
if len_period > 0:
XP.append(np.vstack(x_p))
if len_trend > 0:
XT.append(np.vstack(x_t))
Y.append(y)
timestamps_Y.append(self.timestamps[i])
i += 1
XC = np.asarray(XC)
XP = np.asarray(XP)
XT = np.asarray(XT)
Y = np.asarray(Y)
print("XC shape: ", XC.shape, "XP shape: ", XP.shape, "XT shape: ", XT.shape, "Y shape:", Y.shape)
return XC, XP, XT, Y, timestamps_Y
评论列表
文章目录