Hello everyone,
I have an electricity load time series including trend and two components of seasonality. I want to train my network with an open loop structure but then want to test it with closed loop because I need to forecast next 1,5 years after training the network.
Therefore I updated the narx toolbox script, but I cannot be sure if it is correct. You will see that i defined a new network called netc and recorded its outputs in outputs, so examine the forecast performance with outputsc.
I would be glad if you can take a look to see it is correct.
Thanks in advance..
% Solve an Autoregression Problem with External Input with a NARX Neural Network
% Script generated by NTSTOOL
% Created Sun Feb 03 20:02:41 CET 2013
%
% This script assumes these variables are defined:
%% data - input time series.
% VALUE - feedback time series.
inputSeries = tonndata(data,false,false);targetSeries = tonndata(VALUE,false,false);% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 1:1;feedbackDelays = 1:24;hiddenLayerSize = [10];net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);% Prepare the Data for Training and Simulation
% The function PREPARETS prepares timeseries data for a particular network,
% shifting time by the minimum amount to fill input states and layer states.
% Using PREPARETS allows you to keep your original time series data unchanged, while
% easily customizing it for networks with differing numbers of delays, with
% open loop or closed loop feedback modes.
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);% Setup Division of Data for Training, Validation, Testing
net.divideFcn = 'divideind';%net.divideMode = 'sample';
net.divideParam.trainInd = 1:35104;net.divideParam.valInd = 35105:39104;%net.divideParam.testInd = 39105:43104;
%[inputs,valInd,testInd] = divideind(2000,1:1000,1001:1500,1501:2000);
% Train the Network
[net,tr] = train(net,inputs,targets,inputStates,layerStates);% Test the Network
netc = closeloop(net);y1=targetSeries(39105:43104);u1=inputSeries(39105:43104);[p1,Pi1,Ai1,t1] = preparets(netc,u1,{},y1);outputsc = netc(p1,Pi1,Ai1);errors = gsubtract(t1,outputsc);performance = perform(netc,t1,outputsc)% View the Network
view(netc)
Best Answer