LSTM for time series forecasting

25 次查看(过去 30 天)
Hello,
I am trying to solve a time series forecasting problem and as I am new to deep learning I followed the chickepox example which works well.
For better prediction I want to use 3 more parallel time series data which affect my other time series for prediction. I tried to follow the "time series forecasting using deep learning" example but the training data there, are a part of the time series number. What's the best strategy for handling the above data? Is there an example like mine?
  2 个评论
Debraj Maji
Debraj Maji 2023-12-25
Can you please provide the data you are using?
Nestoras Papadopoulos
My data are in the attached matfile.
time is the hourly times corrspponding to the data.
data holds four timeseries. I want to make prediction for the fourth line. Each cell corresponds to a year.
The fourth timeseries is depended on the three others.
Note: I don't know if it helps, but timeseries in lines 1 and 3 are functions of time. This means that values of them can be calculated in future.
Thanks for your help.

请先登录,再进行评论。

采纳的回答

Shubham
Shubham 2023-12-28
Hi Nestoras,
When you're dealing with multiple parallel time series that affect each other, you're looking at a multivariate time series forecasting problem. Deep learning models, particularly Recurrent Neural Networks (RNNs) like Long Short-Term Memory (LSTM) networks, are well-suited for this kind of task.
The general strategy for handling multivariate time series data is to format your data such that each time step includes feature vectors that incorporate all the relevant variables. For example, if you have four parallel time series (including the original one you're trying to predict), each time step in your input data will include a vector with four elements.
Here are some steps to help you adapt the chickenpox example to your multivariate scenario:
  1. Format your data: As shown in the code snippet above, combine your time series into a single dataset where each time step includes all relevant variables.
  2. Define the architecture of your LSTM network: Depending on the complexity of your problem, you might need to adjust the number of LSTM layers and the number of units in each layer.
  3. Train the LSTM network: Use the formatted data to train the network. Make sure to split your data into training and validation sets to monitor for overfitting.
  4. Evaluate the model: After training, evaluate your model on a test set to see how well it generalizes to unseen data.
  5. Forecast future values: Use the trained model to forecast future time steps. For multivariate forecasting, you will need to provide values for all input variables, not just the historical values of the series you're trying to predict.
Remember to normalize your data if necessary, as LSTM networks are sensitive to the scale of the input data. Also, consider experimenting with different architectures, hyperparameters, and data preprocessing techniques to improve performance.
  2 个评论
Nestoras Papadopoulos
Nice answer and I have already followed it. Just a couple of more questions:
How I define the appropriate hidden units? I tried some numbers (200-500-1000-2000) and the more units I use the RMSE falls (below 0.1 using 2000) but the processing time increases too much. When is it overfitted?
I have gaps in my data. I know that they shouldn't exist in LSTM, so I started to cut the sequnence just before the gap. Another strategy I tried was to make smaller sequences without gaps containing 200-400 time steps but the sequences weren't of the same length. What is the best option?
Thank you very much.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by