-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
80 lines (49 loc) · 2.36 KB
/
main.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
#!/usr/bin/python
import warnings
warnings.filterwarnings('ignore')
import sys
import os
sys.path.append(os.getcwd())
import time
import pickle
from functions import train_DLmodels as train
from functions import utils as utils
from functions import areas_data_structure as ads
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler, StandardScaler
with open('data/linesedges.pkl', 'rb') as input_file:
linesedge = pickle.load(input_file)
time_print = True
n_steps_out = 3
machine = 'Personal_Desktop'
epochs = 1
save = True
samples_test = 252
for n_steps_in in [ 16, 24, 32]:
for i in [1,2,4,5,6]:
each_trip = str(i)
with open('data/linktt/links_area_' + each_trip + '.pkl', 'rb') as input_file:
dataset = pickle.load(input_file)
links = dataset['link'].unique()
groupedData = utils.clean_group_data(dataset, links, 3, '30min')
groupedData= groupedData[links].loc[(groupedData.index.hour > 5)]
# define input sequence
scaler_std = StandardScaler()
scaler = MinMaxScaler()
groupedDataScaled = scaler_std.fit_transform(np.log(groupedData.values))
groupedDataScaled = scaler.fit_transform(groupedDataScaled)
train.train_DL_models(groupedDataScaled, samples_test, each_trip, links, n_steps_in, n_steps_out, epochs, time_print, machine)
for each_trip in ads.a[i]['trips'][:1]:
with open('data/linktt/trip_' + each_trip + '.pkl', 'rb') as input_file:
dataset = pickle.load(input_file)
links_tuples = linesedge[each_trip]
links = utils.linesedge_tuples2string(links_tuples)
groupedData = utils.clean_group_data(dataset, links, 3, '30min')
groupedData= groupedData[links].loc[(groupedData.index.hour > 5)]
# define input sequence
scaler_std = StandardScaler()
scaler = MinMaxScaler()
groupedDataScaled = scaler_std.fit_transform(np.log(groupedData.values))
groupedDataScaled = scaler.fit_transform(groupedDataScaled)
train.train_DL_models(groupedDataScaled, samples_test, each_trip, links, n_steps_in, n_steps_out, epochs, time_print, machine)