How to predict future responses y(t + 1) from the training of a narxnet network with past data of x (t) and y (t)? (NARXNET)

3 views (last 30 days)
Greetings,
I hope someone could help me with the next question:
As input variables for the NARXNET (time series) type neural network I have the following data (cells arrays):
INPUTS: x(t): 1 x 55, each column with 18 x 1. The 18 variables are entries.
OUTPUTS: y(t): 1 x 55, each column with 6 x 1. The 6 variables are outputs.
The 18 input variables are different from 6 output variables. There have high correlations between them. I have a model using a step-by-step regression (multiple) to compare this results with the final results of the NARXNET net. I'm using MSE as statistical error measurement between methods.
I wish to predict Y(1) only by using a input matrix x(t): 1 x 55 (each column 18 x 1 variables).
How could I evaluate the network (net) created using a matrix x(t):1 x 55 (each column 18 x 1 variables) different from the one used during training?
%-------------------------TRAINING RESULTS------------- (ANY COMMENTS ABOUT THIS RESULTS?)
RESULTADOS_NET1.jpg
I'm using the following code from the Matlab examples in ntstool.
This is the code (any correction and suggestion will be welcome):
%---------------------------------------------ANN FORECASTING--------------------------------------------
inputSeries = INPUTS; %x(t): 1 x 55, each column with 18 x 1. The 18 variables are entries.
targetSeries = OUTPUTS; %y(t): 1 x 55, each column with 6 x 1. The 6 variables are outputs.
%Bayesian model
trainFcn = 'trainbr';
% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 1:0;
feedbackDelays = 1:1;
hiddenLayerSize = 30;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
%view(net)
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);
% Set up Division of Data for Training, Validation, Testing
net.divideFcn = 'divideblock';
net.divideMode = 'value';
net.trainParam.epochs = 10000;
net.trainParam.goal = 0;
net.trainParam.lr = 0.001;
net.divideParam.trainRatio = 85/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
%MSE
net.performFcn = 'mse';
% Train the Network
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
% Test the Network
outputs = net(inputs,inputStates,layerStates);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
% figure, plotperform(tr)
% figure, plottrainstate(tr)
% figure, plotregression(targets,outputs)
% figure, plotresponse(targets,outputs)
% figure, ploterrcorr(errors)
% figure, plotinerrcorr(inputs,errors)
% Closed Loop Network
% Use this network to do multi-step prediction.
% The function CLOSELOOP replaces the feedback input with a direct
% connection from the output layer.
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
view(netc)
[xc,xic,aic,tc] = preparets(netc,inputSeries,{},targetSeries);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(netc,tc,yc)
% Early Prediction Network
% For some applications it helps to get the prediction a
% timestep early.
% The original network returns predicted y(t+1) at the same
% time it is given y(t+1).
% For some applications such as decision making, it would
% help to have predicted y(t+1) once y(t) is available, but
% before the actual y(t+1) occurs.
% The network can be made to return its output a timestep early
% by removing one delay so that its minimal tap delay is now
% 0 instead of 1. The new network returns the same outputs as
% the original network, but outputs are shifted left one timestep.
%nets = removedelay(net,1);
nets=net;
nets.name = [net.name ' - Predict One Step Ahead'];
view(nets)
[xs,xis,ais,ts] = preparets(nets,inputSeries,{},targetSeries);
ys = nets(xs,xis,ais);
earlyPredictPerformance = perform(nets,ts,ys)

Accepted Answer

Greg Heath
Greg Heath on 13 Feb 2019
YOU DO NOT HAVE X and Y !!!
YOU HAVE X and T where
T = Ydesired
Hope this helps
Thank you for formally accepting my answer
Greg
  1 Comment
Cesar Diaz
Cesar Diaz on 13 Feb 2019
Hi Greg, thanks for the answer.
But, how I could send a input matrix x(t), different from the training matrix?. Over the last code, do you could help me with that?.
So, the forecasted responses are:
yc = netc(xc,xic,aic); %CLOSED LOOP
ys = nets(xs,xis,ais); %ONE STEP AHEAD
How I could make a new forecast from:
outputs = net(inputs,inputStates,layerStates); %OPENED LOOP
I need to load a new x(t) matrix for make a forecast T(t).
Thanks Greg.

Sign in to comment.

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!