How Can You Get The Following(next) Value Of Stock Price(time Series) With List Using For Loop?
here is my code a = x_test[-1:] b = model.predict(a) c = model.predict(np.array([list(a[0,1:])+[b]])) this is one day predict code in this code a = array([[[0.76165783], [
Solution 1:
I would write a function like this:
def forecast_seq(model, init_seq, n_next_steps):
results = []
curr_seq = init_seq[:]for_ in range(n_next_steps):
# predict the next step and update the current sequence
pred_step = model.predict(np.array([curr_seq]))[0]
curr_seq = np.concatenate([curr_seq[-1:], [pred_step]])
results.append(pred_step)
return results
You can use it this way:
# this will update the last datapoint with the predictions of the next 5 steps:
next_seq_in5 = forecast_seq(model, x_test[-1], 5)
Post a Comment for "How Can You Get The Following(next) Value Of Stock Price(time Series) With List Using For Loop?"