Neural Networks extrapolation (using closed network - multistep prediction) can not even predict a line ?
Afficher commentaires plus anciens
Hi; Is it possible to predict EFFECTIVELY into the future using NAR neural network. I used Neural Networks to predict a simple line using multisteps (closed loop ), but it turns out that it is very good but only till the training part whereas it miserably fails in the multistep (predict ahead ) part. here is my code: Please help, where am I wrong ? %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MULTISTEP PREDICTION USING NAR AND CLOSED LOOP NEURAL NETWORK
clc; clear all; close all;
% A simple line which I want to predict
DATA= (1:1000)';
%% Create a Nonlinear Autoregressive Network
feedbackDelays = 1:5;
hiddenLayerSize = 5;
net = narnet(feedbackDelays,hiddenLayerSize);
net.divideParam.trainRatio = 85/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 0/100; % NO TEST DATA as I only want to test the multistep part in future
net.divideFcn = 'dividerand'; % Divide data randomly
% TRAINING
N=500; % Number of bars used for training
TDATA = DATA(1:N); % Training Data
T = tonndata(TDATA,false,false);
[x,xi,ai,t] = preparets(net,{},{},T); % prepare data
[net,tr] = train(net,x,t,xi,ai); % Train the Network
y = net(x,xi,ai);
% MULTISPTEP PREDICTION - Closed Loop Network
MSDATA = DATA(N-feedbackDelays(end):end); % multistep predict ahead data
T = tonndata(MSDATA,false,false);
netc = closeloop(net);
[xc,xic,aic,tc] = preparets(netc,{},{},T);
yc = netc(xc,xic,aic);
%% PLot training and multistep predicted part
hold on;
plot(cell2mat(t)); % targets in training part
plot(cell2mat(y),'r'); % nn results in training part
plot([nan(1,length(t)'),cell2mat(tc)],'g'); % targets in multistep predicted part
plot([nan(1,length(y)'),cell2mat(yc)],'r'); % nn in multistep predicted part
Réponse acceptée
Plus de réponses (2)
Greg Heath
le 17 Oct 2014
Modifié(e) : Greg Heath
le 17 Oct 2014
1. Do you really expect to confidently predict ahead when you use 'dividerand' ???
2. Both training and validation data are used for design. Therefore if you do not have test data you do not have an UNBIASED estimate of future performance.
3. Conclusion
a. Use a divideFcn which preserves order and constant spacing.
b. Obtain an unbiased estimate of performance on new data using a test set.
Hope this helps.
Thank you for formally accepting my answer
Greg
P.S. IT IS VERY UNFORTUNATE THAT MATLAB USES DIVIDERAND TO BE THE DEFAULT DIVISION FUNCTION IN TIMESERIES FUNCTIONS
1 commentaire
Muhammad Hasnat
le 17 Oct 2014
Greg Heath
le 22 Sep 2015
1. You do not need a hidden layer for a straight line. Therefore, you are overfitting. It is good practice to try to minimize the number of hidden layers and nodes. Otherwise use validation stopping and/or regularization.
2. Test the CL configuration on the OL design data. If you compute the cumulative MSE, you can get an estimate of an upper bound for how many timesteps you can expect to accurately predict.
Hope this helps.
Greg
Catégories
En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!