Bad results in modeling systems, with more than 1 Input, using neural network!

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Greg Heath
Greg Heath il 30 Mag 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 Commenti
Platon
Platon il 11 Giu 2013
Modificato: Platon il 11 Giu 2013
Relevant comments, thank you.
I have another question in relation with that. One time you told to me that when we train a NARX NN with an input vector X the model developed is reliable just for unseen data inputs which have the same mean and variance approximately as X.
For a given unseen Input data I and using this expression Y = STD(X)/STD(I)* (I-mean(I))+mean(X) the Y data have the same mean and variance as X (used for training) nevertheless the network can not predict Output from Input correctly. I create a NARX model and trained it using sin(2pi/20*t) (t is time) but when I test it using sin(2pi/20 *rand(1,1000)) after being preprocessed to have the same mean and variance as sin(2pi/20*t) The performance are bad but I noted that predicted Output fluctuations are the same as actual Output. They seem to be just translated vertically without time delay.
Could You please tell me what is the problem with this issue?
Greg Heath
Greg Heath il 20 Feb 2014
For time series the significant delays have to be approximately the same in addition to the mean and variance.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by