How can I predict new values in NARnet after it has been trained?
Show older comments
Hello! I would like to ask a few simple questions.
I have a 365x24 samples that I would like to use to train a NAR network. After that I want to use it to predict new 24 values with a 1x24 input data.
inPutss = xlsread('Datos','Hoja2');
targetSeries = tonndata(inPutss,false,false);
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narnet(feedbackDelays,hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
[inputs,inputStates,layerStates,targets] = preparets(net,{},{},targetSeries);
net.divideFcn = 'divideblock';
net.divideMode = 'time';
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.trainFcn = 'trainlm';
[net,tr,YY,EE,XFF,AFF] = train(net,inputs,targets,inputStates,layerStates);
outputs = net(inputs,inputStates,layerStates);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
netc = closeloop(net);
[xc,xic,aic,tc] = preparets(netc,{},{},targetSeries);
yc = netc(xc,xic,aic);
perfc = perform(net,tc,yc)
nets = removedelay(net);
[xs,xis,ais,ts] = preparets(nets,{},{},targetSeries);
ys = nets(xs,xis,ais);
closedLoopPerformance = perform(net,tc,yc)
Okay now that I have my network trained, I want to use it to predict new values:
test = xlsread('Datos','Sheet1') %this is a 1x24 vector
test2 = tonndata(test,false,false)
sample1 = net(test2)
sample2 = netc(test2)
sample3 = nets(test3)
My first question is:
1- Which one of the three networks that the script created is the one that I should use to predict next-day values? In other words, which result is better? sample1, sample2 or sample3?
2- How can I add more layers (apart from the hidden ones) and how can I define the number of neurons inside each one of them?
Thanks to anyone that can answer my questions
Accepted Answer
More Answers (0)
Categories
Find more on Modeling and Prediction with NARX and Time-Delay Networks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!