-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeras_production.py
39 lines (33 loc) · 1.29 KB
/
keras_production.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
#!/usr/bin/env python
##############################################################
#
# Commodity price forecast
#
# Alexey Goder
#
# august 29th, 2019
#
##############################################################
import pickle
from keras_train import build_regressor, get_one_prediction
from prepare_input import get_last_friday
from datetime import timedelta
from get_input_data import get_input_vector, get_last_commodity_price
COMMODITY = 'cattle'
with open('keras_model_' + COMMODITY + '.pkl', 'rb') as f:
keras_model = pickle.load(f)
def get_long_term_forecast(keras_model=keras_model):
input_vector = get_input_vector(counter=keras_model['counter'])
forecast_list = keras_model['regressor'].predict(input_vector, steps=None)[:, ].tolist()
start_date = get_last_friday() + timedelta(days=7)
return [get_one_prediction('feeder cattle',
start_date + timedelta(days=i * 7),
get_last_commodity_price(),
forecast_list[i],
keras_model['sigma'][i]
)
for i in range(keras_model['weeks'])
]
if __name__ == "__main__":
print(get_long_term_forecast())