How to perdict timeseries using already trained net from nnstart tool in Matlab
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Muhammad Usman Saleem
am 13 Mai 2023
Kommentiert: Muhammad Usman Saleem
am 15 Mai 2023
Through google I find nnstart tool where I can predict my timeseries dataset, I opened this app and seletec NAR option then select target as martrix column, then after partition my data I used Levenberg-Marquardt as training algothim. After getting best training and validation results I save the model output in my workspace. I want to predict from this train net 5 years ahead of my timeseries data in data variable however whenever I run predict or predictAndUpdate my code below error:
>> predict(net,data)
Error using predict (line 126)
No valid system or dataset was specified.
>> predictAndUpdateState(net,data)
Undefined function 'predictAndUpdateState' for input arguments of type 'network'.
I've called my timeseries data from excel file to matrix data (1,20 size) and want to get predicted data(1,25 size) using this tool. I am also sharing my workspace variables contain input variable data and output variables from train model using nntool (error,info,net,output, results) please guide me how can I predict my data variable 5 steps ahead using this train network? Many thanks for timely reply please
0 Kommentare
Akzeptierte Antwort
LeoAiE
am 13 Mai 2023
here is what I did:
% Load data
load('Test_1.mat');
dataSeries = data;
% Prepare input and target data
X = num2cell(dataSeries, 1);
T = X;
% Define and train the NARX network
inputDelays = 1:2;
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narxnet(inputDelays, feedbackDelays, hiddenLayerSize);
% Divide data into training, validation, and testing sets
net.divideFcn = 'divideblock';
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Prepare the data for training
[xs, xi, ai, ts] = preparets(net, X, {}, T);
% Train the NARX network
[net, tr] = train(net, xs, ts);
% Make predictions
nPredict = 5; % Number of steps ahead to predict
netc = closeloop(net);
[xc, xi, ai, tc] = preparets(netc, X, {}, T);
YPredicted = netc(xc, xi, ai);
% Convert the predicted output back to a matrix format
YPredictedMatrix = cell2mat(YPredicted);
% Transpose the YPredictedMatrix
YPredictedMatrix = YPredictedMatrix';
% Create a new variable to store the original data and the predicted values
6 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!