Clear Filters
Clear Filters

How alignment of data is treated by the neural network algorithms for one day ahead prediction

2 views (last 30 days)
I am having trouble understanding how the alignment of data is treated by the neural network algorithms for one day ahead prediction.
Suppose we have a target T from times 1,2,3…t. Suppose we have inputs X from times 1,2,3,…t. Imagine each time step is one day.
We want to do one step ahead prediction for each day prospectively, day by day. This means we never want to use any future information. Also, we want to predict tomorrow’s target at the end of today. In other words, we want to use X(1:t) and T(1:t) to predict T(t+1); we do not have X(t+1) at our disposal for this purpose, because that information lies in the future.
If we create a narxnet network with X(1:t) and T(1:t) aligned in time, the default output is T(t) which is found using all of X, including X(t).
So instead we convert the network a step ahead network. At time t, this gives us T(t+1) using only data from days 1 through t.
Is this correct? The results I get seem too good to be true.
  3 Comments
Kevin Johnson
Kevin Johnson on 12 May 2018
% inputsnn - input time series. % targetnn - feedback time series.
% note: inputs and target are aligned in time
X = tonndata(inputsnn,false,false); T = tonndata(targetnn,false,false);
% Training Function trainFcn = 'trainbr';
% Create a Nonlinear Autoregressive Network with External Input inputDelays = 1:2; feedbackDelays = 1:2; hiddenLayerSize = 10; netts = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Prepare the Data for Training and Simulation [x,xi,ai,t] = preparets(netts,X,{},T);
% Setup Division of Data for Training, Validation, Testing netts.divideParam.trainRatio = 70/100; netts.divideParam.valRatio = 15/100; netts.divideParam.testRatio = 15/100;
% Train the Network [netts,tr] = train(netts,x,t,xi,ai);
% Test the Network y = netts(x,xi,ai); e = gsubtract(t,y);
% Step-Ahead Prediction Network netsa = removedelay(netts); netsa.name = [netts.name ' - Predict One Step Ahead']; [xs,xis,ais,ts] = preparets(netsa,X,{},T); ys = netsa(xs,xis,ais); resultnn=[NaN;cell2mat(ys)'];

Sign in to comment.

Answers (1)

Greg Heath
Greg Heath on 14 May 2018
Edited: Greg Heath on 14 May 2018
I don't understand your problem.
What fraction of the target variance did you want to achieve?
mse(error)/mean(var(target',1)) <= ?
Greg

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!