How to perdict timeseries using already trained net from nnstart tool in Matlab
10 ビュー (過去 30 日間)
古いコメントを表示
Muhammad Usman Saleem
2023 年 5 月 13 日
コメント済み: Muhammad Usman Saleem
2023 年 5 月 15 日
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!