I am having an issue with how to tell my RNN-LSTM model
to generate future values. I think that I need to append values to "inputs" so that X_test
extends beyond my test data set and into the future, but how should I go about that, or what should those values be? Go easy on me here, just getting into python/machine learning.
X_test.shape = (193, 60, 5)
by the end of this code, by the way, containing " Open, High, Low, Close, Volume " values.
past_60_days = data_training.tail(60)
df = past_60_days.append(data_test, ignore_index = True)
df = df.drop(['Date', 'Adj Close'], axis = 1)
inputs = scaler.transform(df)
X_test = []
y_test = []
for i in range(60, inputs.shape[0]):
X_test.append(inputs[i-60:i])
y_test.append(inputs[i, 0])
X_test, y_test = np.array(X_test), np.array(y_test)
y_pred = regressior.predict(X_test)
Your problem is Time Series Analysis
and yes, Forecasting the Future Predictions can be done using LSTM
(RNN).
For example, you want to Forecast Next Days Value, considering past 60 days Data, important part of code would be
def multivariate_data(dataset, target, start_index, end_index, history_size,
target_size):
data = []
labels = []
start_index = start_index + history_size
if end_index is None:
end_index = len(dataset) - target_size
for i in range(start_index, end_index):
indices = range(i-history_size, i)
data.append(dataset[indices])
labels.append(target[i:i+target_size])
return np.array(data), np.array(labels)
past_history = 60
future_target = 1
x_train, y_train = multivariate_data(dataset, dataset[:, 0], 0,
training_data_len, past_history,
future_target)
x_val_single, y_val_single = multivariate_data(dataset, dataset[:, 0],
training_data_len, None, past_history,
future_target)
Please refer this Comprehensive Tensorflow Tutorial which has the complete code for Multi-Variate Data
(Multiple Columns like Open, Close, High, Low, etc..
), which Predicts a Single Step
and Multiple Steps
.
If you face any error while implementing it, please reach out and I will be Happy to help you.
Hope this helps. Happy Learning!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.