-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_data.py
53 lines (44 loc) · 1.69 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
46
47
48
49
50
51
52
53
# -*- 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_testtdgcn_data(dataset):
cq504_adj = pd.read_csv(r'data/testdata/test_OHe.csv', header=None)
adj = np.mat(cq504_adj)
cq504_cql = pd.read_csv(r'data/testdata/CBM_Production.csv')
cq504_cql = cq504_cql.fillna(0)
return cq504_cql, adj
def load_testtgcn_data(dataset):
cq504_adj = pd.read_csv(r'data/testdata/test_OH1.csv', header=None)
adj = np.mat(cq504_adj)
cq504_cql = pd.read_csv(r'data/testdata/CBM_Production.csv')
cq504_cql = cq504_cql.fillna(0)
return cq504_cql, adj
def load_test_data(dataset):
spametrics = pd.read_csv(r'data/testdata/test_Spamatrix.csv', header=None)
spametrics = np.mat(spametrics)
prod = pd.read_csv(r'data/testdata/CBM_Production.csv')
prod = prod.fillna(0)
return prod, spametrics
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