MultiVariate Regression with LSTM
MultiVariate Regression with LSTM
Loading saved threads...
Ramesh · External communityPost link
External question — Data Science Stack Exchange
Author: Ramesh
Original post: https://datascience.stackexchange.com/questions/20033
License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I am interested to use multivariate regression with LSTM (Long Short Term Memory).
As an example, we can take the stock price prediction problem, where the price at time t is based on multiple factors (open price, closed price, etc.). Using this information we need to predict the price for t+1.
Another example can be the house price prediction (which depends on factors like, age of house, area, no. of beds, no. of baths, etc). Using this information, we can predict the price of a given house.
I have found many examples where they just used a single variable regression, but I am interested to use multiple features.
Has anyone tried this and can anyone point out the right direction for this?
I tried the following but have no idea if this is the efficient way.
# Importing the training set
training_set = pd.read_csv('Google_Stock_Price_Train.csv').iloc[:,1:3].values#has fields: Date,Open,High,Low,Close,Volume
# Feature Scaling
from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler()
training_set_scaled = sc.fit_transform(training_set)
X_train = training_set_scaled[0:1257]
y_train = training_set_scaled[1:1258]
# Reshaping
X_train = np.reshape(X_train, (1257, 1, 2))
X_train, y_train = np.array(X_train), np.array(y_train)
X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 2))
from keras.models import Sequential
from keras.layers import Dense, LSTM
regressor = Sequential()
regressor.add(LSTM(units = 4, activation = 'sigmoid', input_shape = (None, 2)))
regressor.add(Dense(units = 2))
regressor.compile(optimizer = 'rmsprop', loss = 'mean_squared_error')
regressor.fit(X_train, y_train, batch_size = 32, epochs = 100)
Thanks.
Quote
Report
tomar__ · External communityPost link
External answer — Data Science Stack Exchange
Author: tomar__
Original post: https://datascience.stackexchange.com/a/23019
License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Here's a great example for Multivariate Regression using LSTM:
https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/
Most Examples you will find will be for time-series prediction using LSTM, like the one you listed for Stock Prices.
Quote
Report
Ajinkya Bankar · External communityPost link
External answer — Data Science Stack Exchange
Author: Ajinkya Bankar
Original post: https://datascience.stackexchange.com/a/116140
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Here is the elegant research paper with the python implementation of multivariate regression using GRU, LSTM, and GAN for stock prediction:
https://github.com/hungchun-lin/Stock-price-prediction-using-GAN
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Data Science Stack Exchange Author: tomar__ Source score (net votes, not local likes): 7 Original post: https://datascience.stackexchange.com/a/23019 License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Here's a great example for Multivariate Regression using LSTM: https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/ Most Examples you will find will be for time-series prediction using LSTM, like the one you listed for Stock Prices.
Checking account access…