Predict futures values in ntstool (NAR)

1 view (last 30 days)
I have used ntstool to create a neural network say net . I am using NAR. I have a vector v of size 271 x 1 having data of an element at 271 timesteps. I am assuming d to be 5 , i.e, value at each step is dependent of 5 previous steps. Now I need the value of my element at 272th step. What is the syntax to do do?
A peculiar observation is the command sim(net,t); or net(t); where t is any row vector returns me same value independent on the choice of vector t.
Here is my training function:
function results = time_series(input,hiddenLayerSize,train_function, validation_no,test_no,time_step,iterations)
targetSeries = tonndata(input,false,false);
feedbackDelays = 1:time_step;
net = narnet(feedbackDelays,hiddenLayerSize);
% Choose Feedback Pre/Post-Processing Functions
% Settings for feedback input are automatically applied to feedback output
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
[inputs,inputStates,layerStates,targets] = preparets(net,{},{},targetSeries);
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'time'; % Divide up every value
net.divideParam.trainRatio = (100-validation_no-test_no)/100;
net.divideParam.valRatio = validation_no/100;
net.divideParam.testRatio = test_no/100;
net.trainFcn = train_function; % Levenberg-Marquardt
for i= 1:iterations
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
end;
% View the Network
%view(net);
if(closed_loop)
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);
end
results.net = net;
results.inputs = inputs;
end

Accepted Answer

Greg Heath
Greg Heath on 9 May 2014
1. The best way to get help is to run your code on the command line with one of the MATLAB example data sets. See
help narnet
doc narnet
or
help nndatasets
doc nndatasets
Then post questions with supporting relevant code, error messages and results.
2. Find the delays from the significant delays of the autocorrelation function
3. Find the number of hidden nodes by trial and error. Do not use more than you need.
4. Use divideblock, NOT dividerand to keep from ruining the time correlation structure.
5. Search for posted examples in the NEWSGROUP, then in ANSWERS. Use the searchwords
greg narnet
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!