MATLAB Answers

0

Neural network time series prediction with ANN Toolbox

Asked by Shiladitya Chatterjee on 14 Aug 2016
Latest activity Answered by Abolfazl Nejatian on 23 Nov 2018
Hello all, I know this question has been asked several times but I would still want to know. I am a beginner in Matlab and I have been experimenting with ANN toolbox. I have managed to train a NARX neural network with a set of input and target values and now an advanced script is generated. My training input is a 200 day dataset of 5 days each that is it takes input of 5 days and predicts the 6th day.
My question is, how do I feed new inputs to this network to make predictions? That is, now, I wanna just take 5 previous including the current day and predict the value for tomorrow? How do I pass this 5 day input set and predict the target?
Thank you

  0 Comments

Sign in to comment.

3 Answers

Answer by Greg Heath
on 23 Aug 2016
 Accepted Answer

For NARNET and NARXNET to be useful, target input values used in the openloop (OL) design have to be replaced by feedback from the output. This is accomplished via the CLOSELOOP (CL) command.
Very often, however, the resulting CL configuration is either not as accurate or is completely useless.
UNFORTUNATELY THERE IS NOTHING IN THE help OR doc DOCUMENTATION ABOUT THIS.
I have been struggling to devise a successful technique for improving the accuracy of CL designs. If you search both the NEWSREADER and ANSWERS with
greg closeloop
you will see my efforts to resolve this issue.
All I can recommend at this time is the following
1. Try to obtain the lowest error rate possible with as few delays and hidden nodes as possible using the OL configuration. The fewer weights you have to estimate, the higher your probability of success.
2. The default values ID = 1:2, FD = 1:2, H = 10 are very often inadequate. Nevertheless, since you may have to make tens or even hundreds of OL designs before obtaining a successful CL design, I suggest that you ALWAYS start with the defaults.
3.
a. Successful input delays tend to be subsets of the significant delays
obtained from the statistically significant peaks of the crosscorrelation
functions of paired inputs and outputs.
b. Successful feedback delays tend to be subsets of the significant
delays obtained from the statistically significant peaks of the target
autocorrelation function.
c. Success usually results from choosing a reasonably sized subset of the delays
found in a and b.
4. For each trial combination of delays, you can use a double loop design search over number of hidden nodes (outerloop h = Hmin:dH:Hmax) and initial random weights (inner loop: i = 1:Ntrials).
For examples search the NEWSREADER and ANSWERS using the search words
greg Ntrials narxnet
5. For unbiased future predictions the test data subset data must occur after the training and validation subsets. The natural datadivision option to use is DIVIDEBLOCK. However, other trn/val configurations using divideind can certainly be used.
6. After achieving success with at least one OL design, use the CLOSELOOP command to replace target inputs with output feedback.
7. Unfortunately, when the loop is closed, very often the predictions are not as accurate or even completely useless.
8. The only other remedies I have to offer are
a. Try CL designs from all of the other successful OL designs
b. Train the CL configuration(s) initialized with the weights of the OL configuration(s).
c. Try designing CL designs from random initial weights.
Hope this helps.
Thank you for formally accepting my answer
Greg

  0 Comments

Sign in to comment.



I am assuming you are referring to Neural Network Toolbox when you say "ANN Toolbox". My understanding of the issue is you have trained the NARX neural network successfully but you want to know how to test/use the trained network.
Refer to Neural Network Time Series Prediction and Modeling, this explains the steps to train and test the network. Step 6 in this link explains about the GUI interface to validate and test network.
You can also find the sample script in Step 17. The commands to train and test the network would be as below:
% Train the Network
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
% Test the Network
outputs = net(inputs,inputStates,layerStates);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)

  4 Comments

Show 1 older comment
Well,
My apologies if I couldn't explain myself clearly. I have understood the training and testing part. What I want to know is how to make predictions with just the input values now without any target and get the predicted value out
Hello Swathik,
My question is How do I predict outputs on this trained network based on just inputs? Since I want to predict future, I do not have an target values.
Hello Shiladtiya, I have the same question. Did you find out how to predict outputs on the trained network based on just inputs? I am using this command but it gives error. yPred= sim(net,X')';

Sign in to comment.


Answer by Abolfazl Nejatian on 23 Nov 2018

here is my code,
this piece of code predicts time series data by use of deep learning and shallow learning algorithm.
best wishes
abolfazl nejatian

  0 Comments

Sign in to comment.