Bad results in modeling systems, with more than 1 Input, using neural network!
1 view (last 30 days)
Show older comments
I'm getting started with the NN tool box for modeling systems with time delays so I started with an example which goal is to identify the following relation: y(t)=exp(x(t-2))-3*x(t-1).
This is the program I used to find a NN which can simulate the relation y(t) = F( x(t-1), x(t-2) ) :
1. First I create the Input and Output for training
xt=rand(1,100);
for i=3:100 yt(i)=exp(xt(i-2))-3*xt(i-1); end
2. Then I train Hmax*Niter networks
rng(0)
inputSeries = tonndata(xt',false,false);
targetSeries = tonndata(yt',false,false);
Hmax=10;
Niter = 10;
for i = 1:Hmax for j = 1:Niter
inputDelays = 1:2;
hiddenLayerSize = i;
net = timedelaynet(inputDelays,hiddenLayerSize);
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,targetSeries);
net.divideFcn = '';
net.trainFcn = 'trainbr';
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
end
end
3. I select the best network with R2 close to 1.
4. I evaluate the network with unseen data.
xe=rand(1,100);
for i=3:100 ye(i)=exp(xe(i-2))-3*xe(i-1); end
inputSeries = tonndata(xe',false,false);
targetSeries = tonndata(ye',false,false);
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,targetSeries);
outputs = net(inputs,inputStates,layerStates);
P=cell2mat(outputs);
O=cell2mat(targets);
plot(P)
hold on
plot(O,'r')
Here is the results: I used 2 for ID because I know it in advance anyway, I found a lot of networks with R2 close to 1, go to the following figure for the training data results.
for unseen data :
xe=3*rand(1,100);
for i=3:100 ye(i)=exp(xe(i-2))-3*xe(i-1); end
for input so large like xe= 5 *rand(1,100) the network model give bad results which is normal.
Unfortunately I can't find the same results when I try to identify the following relation with 2 inputs y(t)=w(t-1)*w(t-2)*exp(x(t-2))-3*x(t-1). In fact for the training data I get R2 close to 1 like the first equation but for unseen data in the same range of the training one ( xe=rand(1,100); we=rand(1,100);) the predicted values don't match the actual ones.
I evaluated the net using
inputSeries = tonndata([xe;we]',false,false);
targetSeries = tonndata(ye',false,false);
I'm sure that if I would identify another equation with more than 2 inputs and outputs I'll have bad results too. Could someone help me with this issue? It would be so helpfull if you post your code which allow you to have good results for more than 1 inputs.
Thanks in advance.
0 Comments
Accepted Answer
Greg Heath
on 30 May 2013
Violations of basic assumptions:
1. All input data are assumed to have been drawn from the same source. Violated by xt = rand(1,100) and xe = 3*rand(1,100)
2. ID = [ 1,2 ] contains lags at which there are significant cross-correlations between input and output.
zx = zscore(x,1);
zw = zscore(w,1);
zy = zscore(y,1);
lags = -(N-1):N-1
xcorryx = nncorr(zy,zx,N-1,'biased');
xcorryw = nncorr(zy,zw,N-1,'biased');
Are xcorryx(N+1:N+2) and xcorryw(N+1:N+2) significant?
Hope this helps.
Thank you for formally accepting my answer
Greg
5 Comments
Greg Heath
on 20 Feb 2014
For time series the significant delays have to be approximately the same in addition to the mean and variance.
More Answers (0)
See Also
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!