How can I predict new values in NARnet after it has been trained?
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Greg Heath
2014-9-10
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)
performance = perform(net,targets,YY)
'GEH1: NO PROOF THAT THE OL NET IS SUCCESSFUL' ; ' e.g., performance << var(cell2mat(transpose(targets)),1)' ;
netc = closeloop(net);
[xc,xic,aic,tc] = preparets(netc,{},{},targetSeries);
yc = netc(xc,xic,aic);
perfc = perform(net,tc,yc)
'GEH2: NO PROOF THAT THE CL NET IS SUCCESSFULL';
nets = removedelay(net);
'GEH3: ERROR: CANNOT HAVE 0 FEEDBACK DELAY';
[xs,xis,ais,ts] = preparets(nets,{},{},targetSeries);
ys = nets(xs,xis,ais);
closedLoopPerformance = perform(net,tc,yc)
'GEH4: TYPO: REPLACE net WITH nets ' ;
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)
' GEH5: ERROR : REPLACE test3 WITH test2 ';
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?
' GEH6: NONE OF THE ABOVE. ';
' a. sample1 is openloop';
' b. sample3 cannot exist with with 0 feedback delay';
' c. sample2 has no specified Xic,Aic.';
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?
'GEH7: net = narnet( FD, [H1 H2 H3])';
Thanks to anyone that can answer my questions
Hope this helps.
Thank you for formally accepting my answer
Greg
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!