- You're using the test target variable YTest when you should use the test input XTest for prediction.
- When initializing the network before prediction, you're using the last row of YTrain, but you should use the last row of XTrain instead.
Multivariate Time Series Forecasting using LSTM
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am working to do a Time Series Forecasting using Deep Learning LSTM.
The data file is MSLSTMR.CSV and it contains a sequencial information column 1 to 17, and must results in the columns 18 to 23 ( to corresponding n+1). So data in line n (column 1 to 17 - Independente Variables) must generate the results in line n+1 (columns 18 to 23 - Dependente variables).
The code file is deep_learning_2_Multivariate and is generating error during execution because do not allocate the correct inputs to train.
I have tested using one Independente Variable ( only column 1) with One Dependente Vabiable ( one from column 18 to 23) and the code for this work, but do not have sufficient information to generate good forecasting.
How can i correct the code to work with Multivariate?
0 comentarios
Respuestas (1)
Anay
el 29 de Mayo de 2025
Editada: Anay
el 29 de Mayo de 2025
Hi Geraldo,
I understand that you want to use columns 1 to 17 of your data as input variables, and the remaining columns as target variables.
The reason your code is throwing an error is that you're using “numel(data)” to get the number of rows. However, “numel” returns the total number of elements, not the number of rows, which is why you're getting an indexing error. To get the number of rows, you should use “size(data, 1)” instead.
After splitting your dataset, you should separate the columns used for input and target variables as follows:
XTrain = trainData(1:end-1, 1:17);% Input features
YTrain = trainData(2:end, 18:23);% Target variables
% Similarly for test set
XTest = testData(1:end-1, 1:17);
YTest = testData(2:end, 18:23);
Make sure your model is set up to accept 17 features as input and produce 6 features as output.
There are a couple of problems in how your code handles prediction:
These changes will help you run your code successfully.
0 comentarios
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!