Is there a method to predict one point in the future based on multiple point of past prediction? (LSTM univariate)
1 次查看(过去 30 天)
显示 更早的评论
To explain the title above, how do i get prediction for i+1 based on i and i-1 combined?
I had already done the training and got the training info inside variable net.
This is an example of the code for LSTM trained net to predict 1 value into the future from Mathworks website.
for i=1:numTimeStepsTest
[net,YPred(:,i)] = predictAndUpdateState(net,YPred(:,i-1));
end
I appreciate if anyone can help direct me to any forum/article regarding this matter if it has been answered previously.
Thank you.
0 个评论
回答(1 个)
arushi
2024-8-16
Hi Revaldo,
I understand that you want to obtain a prediction for the next time step (i+1) based on the previous two time steps (i and i-1) using a trained LSTM network in MATLAB.
To get a prediction for ‘i+1’ based on ‘i’ and ‘i-1’ combined using a trained LSTM network in MATLAB, you can modify the code you provided as follows:
% Assuming you have already trained the LSTM network and have it stored in the variable 'net'
% Initialize variables
numTimeStepsTest = ...; % Specify the number of time steps for testing
YPred = zeros(...); % Initialize the prediction array
% Perform prediction for each time step
for i = 2:numTimeStepsTest
% Combine inputs for prediction
combinedInput = [YPred(:, i-1), YPred(:, i-2)]; % Combine previous predictions
% Predict the next time step and update the network state
[net, YPred(:, i)] = predictAndUpdateState(net, combinedInput);
end
Please refer to the following MATLAB File Exchange link for more information:
Please refer to the following MATLAB Documentation link to know more about LSTM:
Hope the above solution helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!