Bad results in modeling systems, with more than 1 Input, using neural network!
1 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
for unseen data :
xe=3*rand(1,100);
for i=3:100 ye(i)=exp(xe(i-2))-3*xe(i-1); end
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
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);
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
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 个评论
采纳的回答
Greg Heath
2013-5-30
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 个评论
Greg Heath
2014-2-20
For time series the significant delays have to be approximately the same in addition to the mean and variance.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling and Prediction with NARX and Time-Delay Networks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!