How can I use LSTM networks to solve a time series regression problem?
57 views (last 30 days)
Show older comments
MathWorks Support Team
on 10 May 2018
Edited: MathWorks Support Team
on 25 Oct 2022
How can I use LSTM networks to solve a time series regression problem? I would like to train a LSTM regression network using all but the last 10 time steps and then test it to see how well the model has done using the last 10 steps of time series that were not used in the training.
Accepted Answer
MathWorks Support Team
on 10 May 2018
To forecast the values of future time steps of a sequence, you can train a sequence-to-sequence regression LSTM network, where the responses are the training sequences with values shifted by one time step. That is, at each time step of the input sequence, the LSTM network learns to predict the value of the next time step.
Please refer to the attached example, "TimeSeriesForecastLSTM.mlx", which demonstrates how to forecast time-series data using a long short-term memory (LSTM) network.
This example trains an LSTM network to forecast the number of chickenpox cases given the number of cases in previous months. The training data contains a single time series, with time steps corresponding to months and values corresponding to the number of cases.
Further, you mentioned that you need to forecast the values for the last 10 steps. To forecast the values of multiple time steps in the future, you can use the "predictAndUpdateState" function to predict time steps one at a time and update the network state at each prediction. Please refer to the documentation of the "predictAndUpdateState" function for more information on how to use the function by typing the following command in the Command Window:
>> doc predictAndUpdateState
3 Comments
Dan Hendrickson
on 1 May 2020
Hi Mohamed and Viktor,
If you have additonal questions about LSTM nets please contact MathWorths technical support and they can assist you further.
best,
Dan
More Answers (4)
Abolfazl Nejatian
on 8 Dec 2018
Edited: MathWorks Support Team
on 25 Oct 2022
here is my code,
this piece of code predicts time series data by use of deep learning and shallow learning algorithm.
best wishes
Abolfazl Nejatian
1 Comment
Ana Correia
on 4 Jun 2018
I can't seem to use this example with MATLAB r2017b. It says 'adam' is not a valid solver name and when I switch to 'sgdm' i get this error: "Regression is not supported for networks with LSTM layers."
Is this example only supported by r2018a?
Thanks in advance for your help.
0 Comments
Said Benkaciali
on 15 Feb 2022
Dear
I have the honnor to ask you to explain the LSTM model for forecasting a global solar irradiation for one hour ahead forecast or if it is possible send me a matlab code.
Thank you
0 Comments
Said Benkaciali
on 15 Feb 2022
Dear
I have the honnor to ask you to explain the LSTM model for forecasting a global solar irradiation for one hour ahead forecast or if it is possible send me a matlab code.
Thank you
Name: Said
Email: sbenkaciali@gmail.com
0 Comments
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!