keras_bitget / utils /preprocess /projections.py
ashhadahsan
commit one
e59b179
raw
history blame
1.13 kB
from numpy import array
def project(time_step: int, test_data, model, days: int = 30):
x_input = test_data[len(test_data) - time_step :].reshape(1, -1)
temp_input = list(x_input)
temp_input = temp_input[0].tolist()
lst_output = []
n_steps = time_step
i = 0
pred_days = days
while i < pred_days:
if len(temp_input) > time_step:
x_input = array(temp_input[1:])
# print("{} day input {}".format(i,x_input))
x_input = x_input.reshape(1, -1)
x_input = x_input.reshape((1, n_steps, 1))
yhat = model.predict(x_input, verbose=0)
# print("{} day output {}".format(i,yhat))
temp_input.extend(yhat[0].tolist())
temp_input = temp_input[1:]
# print(temp_input)
lst_output.extend(yhat.tolist())
i = i + 1
else:
x_input = x_input.reshape((1, n_steps, 1))
yhat = model.predict(x_input, verbose=0)
temp_input.extend(yhat[0].tolist())
lst_output.extend(yhat.tolist())
i = i + 1
return lst_output