-
Notifications
You must be signed in to change notification settings - Fork 753
/
request.py
36 lines (27 loc) · 1.05 KB
/
request.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
"""
Module that sends a practical request to the tf-server
"""
import numpy as np
from . import request_helper #pylint: disable=relative-beyond-top-level
from .. import preprocess #pylint: disable=relative-beyond-top-level
def send_pratical_request(date="2014-08-12"):
""" function that gets the prediction for a certain date in the test set
Args:
date:
Returns:
"""
# create input from request date
tickers = ['snp', 'nyse', 'djia', 'nikkei', 'hangseng', 'ftse', 'dax', 'aord']
closing_data = preprocess.load_data(tickers)
index = closing_data.index.get_loc(date) - 7
# because first 7 days are not accounted in the time series
training_test_data = preprocess.preprocess_data(closing_data)
input_tensor = np.expand_dims(
training_test_data[training_test_data.columns[2:]].values[index],
axis=0).astype(np.float32)
# send request
value, version = request_helper.send_request(input_tensor)
# print response
print("Prediction : " + str(value))
print("Version of model : " + str(version))
send_pratical_request()