- 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 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Anay
2025년 5월 29일
편집: Anay
2025년 5월 29일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!