Time series in Artificial neural network (ANN) example pollution Mortality

5 views (last 30 days)
[X,T] = pollution_dataset
net = timedelaynet(1:2,10);
[Xs,Xi,Ai,Ts] = preparets(net,X,T);
net = train(net,Xs,Ts,Xi,Ai);
I used this very simple example code to get a feel; how a time series network predict a future value. So, what I did instead of using 508 dataset for inputs and outputs. I reduced it to 502 dataset and then tried to get 503rd target by using 503rd input vector.
My simple code was
>> d={[80.3800000000000;57.3100000000000;4.34000000000000;1.57000000000000;9.73000000000000;40.0100000000000;6.99000000000000;47.2200000000000]};
>> a=net(d);
This gave me the following results
281.7230
29.0219
157.1554
While actual output should be
149.220000000000
7.88000000000000
73.4600000000000
Why this is giving so deviated values?....Any Explanation Please!

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 29 Jul 2013
Here is an example I shared sometime earlier. The example predicts 30 steps of a sine wave:
You may use it as a template but that does not mean your network will predict the exact values. You will have to play with the different options before you get your ideal result.
  4 Comments
sandeep
sandeep on 31 Jul 2013
Sir, I am using narxnet because I have data of 351 days of a company for biogas generation. What I understand that since these are data of different dates. So it is a time series and hence I used timedelay network.
Sir, my main problem is that my training set error is decreasing, but validation set error and test set error stopped decreasing after 2 to 5 iteration. Hence my validation performance is always in 6 digit like 573290.71 or 732357.83 etc.
And since test set performance is of this amount then How can I expect to get a good prediction.
I am playing with different numbers of neurons, layers, divideFcn, training algorithm and so on. But performance always remain in 6 digit!!!
What could I do?
sandeep
sandeep on 1 Aug 2013
Shashank Sir, How to modify your code When I have 3 dimensional outputs.
newTargetSet = nan(size(newInputSeries))
newTargetSet = num2cell(newTargetSet )
newTargetSet (1:10) = targetSeries(end-9:end)
[xc,xic,aic,tc] = preparets(netc,newInputSeries,{},newTargetSet);
yPredicted = sim(netc,xc,xic,aic)
I tried but it gives an error Feedback{1,11} and Feedback{1,1} have different numbers of rows.
I want to get my first element of output and take error.
I wrote code for calculating errors % for 1 dimensional output.
errors1 = gsubtract(yPredicted(1:end-1),toPredict);
errors4=cell2mat(errors1);
errors5=(abs(errors4)./y(321 : end))*100;
How Can I write this for 3 dimensional output. I want %error for output element 1.
Thanking You!
Sandeep

Sign in to comment.

More Answers (2)

Greg Heath
Greg Heath on 28 Jul 2013
Edited: Greg Heath on 29 Jul 2013
1. You should not use the default divide function DIVIDERAND in a timeseries. Although I recommend DIVIDEBLOCK, DIVIDEIND or DIVIDEINT could also be used.
2. Normalize the target series to have zero mean and unit variance (help zscore)
3. Initialize the RNG before creating the net
4. [ net tr Y Xf Af ] = train(net,Xs,Ts,Xi,Ai);
5. Make sure the design is good
tr = tr
6. If not make multiple designs until you find a good one
7. Make sure the delay buffer is loaded when you run the new data.
Hope this helps.
Thank you for formally accepting my answer
Greg
P.S. Search timedelaynet greg
  4 Comments
sandeep
sandeep on 31 Jul 2013
I am already using this command for training.
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
which gives tr as a output.
But I don't know how to exploit tr.
sandeep
sandeep on 31 Jul 2013
Sir, I have also a problem with your 3rd point about RNG. Could you give me an example for this which makes things clear?

Sign in to comment.


Greg Heath
Greg Heath on 31 Jul 2013
rng(0)
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
tr = tr % No semicolon
  12 Comments
Greg Heath
Greg Heath on 3 Sep 2013
You are giving your interpretation of what you did and comparisons. It is too confusing without seeing your code. Please stay with the MATLAB dataset.
Shashank Prasanna
Shashank Prasanna on 3 Sep 2013
sandeep, if you have a new or related question please create/ask a new question. This will (1) give your question more visibility and (2) allow you to give credit to who ever answers your question.

Sign in to comment.

Categories

Find more on Sequence and Numeric Feature Data Workflows 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!