How to perdict timeseries using already trained net from nnstart tool in Matlab
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
LeoAiE
2023-5-13
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 个评论
更多回答(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!