Borrar filtros
Borrar filtros

Is there a method to predict one point in the future based on multiple point of past prediction? (LSTM univariate)

2 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Aman Banthia
Aman Banthia el 22 de Sept. de 2023
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.
Best Regards,
Aman Banthia

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by