def timeseries2seqs_meta(data, timestamps, length=3, T=48):
raw_ts = copy(timestamps)
if type(timestamps[0]) != pd.Timestamp:
timestamps = string2timestamp(timestamps, T=T)
offset = pd.DateOffset(minutes=24 * 60 // T)
breakpoints = [0]
for i in range(1, len(timestamps)):
if timestamps[i-1] + offset != timestamps[i]:
print(timestamps[i-1], timestamps[i], raw_ts[i-1], raw_ts[i])
breakpoints.append(i)
breakpoints.append(len(timestamps))
X = []
Y = []
avail_timestamps = []
for b in range(1, len(breakpoints)):
print('breakpoints: ', breakpoints[b-1], breakpoints[b])
idx = range(breakpoints[b-1], breakpoints[b])
for i in range(len(idx) - length):
avail_timestamps.append(raw_ts[idx[i+length]])
x = np.vstack(data[idx[i:i+length]])
y = data[idx[i+length]]
X.append(x)
Y.append(y)
X = np.asarray(X)
Y = np.asarray(Y)
print("X shape: ", X.shape, "Y shape:", Y.shape)
return X, Y, avail_timestamps
评论列表
文章目录