Reputation: 313
I've been following the tutorial here and I have data in and I want to predict future data from everything that I currently have of the test set.
Here is the code I have now. I am completely new to ML and python (I usually do Java) so this is like reading Chinese, but I've copied and pasted it. Currently, it predicts from the start of the data, but I want it to start at the end.
def predict_future(model, data, window_size, prediction_len):
curr_frame = data[-3]
predicted = []
for i in range(len(data), len(data)+ prediction_len):
predicted.append(model.predict(curr_frame[newaxis, :, :])[0, 0])
curr_frame = curr_frame[1:]
curr_frame = np.insert(curr_frame, [window_size - 1], predicted[-1], axis=0)
return predicted
I would appreciate all the help I can get, I have a very limited scope of knowledge on this.
Upvotes: 0
Views: 1165
Reputation: 768
What is currently going on is that the current frame at each iteration of the loop is set to every remaining data except the current one. We can keep the same structure and just flip each row.
At the beginning of your function, you can reverse the data to make the predictions start from the end and go towards the beginning by adding the line data = np.flip(data, axis=0)
which reverses each row of data
.
Upvotes: 1