forked from lehaifeng/T-GCN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_data.py
45 lines (36 loc) · 1.29 KB
/
input_data.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
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 10 15:15:50 2018
@author: Administrator
"""
import numpy as np
import pandas as pd
import pickle as pkl
def load_sz_data(dataset):
sz_adj = pd.read_csv(r'data/sz_adj.csv',header=None)
adj = np.mat(sz_adj)
sz_tf = pd.read_csv(r'data/sz_speed.csv')
return sz_tf, adj
def load_los_data(dataset):
los_adj = pd.read_csv(r'data/los_adj.csv',header=None)
adj = np.mat(los_adj)
los_tf = pd.read_csv(r'data/los_speed.csv')
return los_tf, adj
def preprocess_data(data, time_len, rate, seq_len, pre_len):
train_size = int(time_len * rate)
train_data = data[0:train_size]
test_data = data[train_size:time_len]
trainX, trainY, testX, testY = [], [], [], []
for i in range(len(train_data) - seq_len - pre_len):
a = train_data[i: i + seq_len + pre_len]
trainX.append(a[0 : seq_len])
trainY.append(a[seq_len : seq_len + pre_len])
for i in range(len(test_data) - seq_len -pre_len):
b = test_data[i: i + seq_len + pre_len]
testX.append(b[0 : seq_len])
testY.append(b[seq_len : seq_len + pre_len])
trainX1 = np.array(trainX)
trainY1 = np.array(trainY)
testX1 = np.array(testX)
testY1 = np.array(testY)
return trainX1, trainY1, testX1, testY1