NARX Neural Network test on new test set?

3 次查看(过去 30 天)
After training NARX net.I want to evaluate the model on independent test set "testX'".But it returns me an error.I am testing the model by forecastLoad = sim(net, testX')'.Do we need to add delays in test set also?i don't know where i am making a mistake.
%Create training set
trainInd = data.NumDate < datenum('2008-01-01');
trainX = X(trainInd,:);
trainY = data.SYSLoad(trainInd);
% Create test set to test later
testInd = data.NumDate >= datenum('2008-01-01');
testX = X(testInd,:);
testY = data.SYSLoad(testInd);
testDates = dates(testInd);
%Neural network
X = tonndata(trainX,true,false);
T = tonndata(trainY,true,false);
% Choose a Training Function
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 1:25;
feedbackDelays = 1:25;
hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Prepare the Data for Training and Simulation
[x,xi,ai,t] = preparets(net,X,{},T);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t,xi,ai);
% Test the Network
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y)
% View the Network
view(net)
%%Forecast using Neural Network Model
% Once the model is built, perform a forecast on the independent test set.
load Data\testSet
forecastLoad = sim(net, testX')';

回答(1 个)

Greg Heath
Greg Heath 2017-9-13
编辑:Greg Heath 2017-12-29
The best way to begin:
Upper case for cell variables
Lowercase for noncells
Subscript o for openloop (OL)
Subscript c for closed loop (CL)
Read X & T
Define x & t using cell2mat
Determine sizes of x and t
Use divideblock so that train, val & test
are sensibly ordered for predicting the
future using a constant timestep size.
3-color plots of x= [xtrn xval xtst] and t = ...
Use xtrn, ttrn, and nncorr to determine the
values of the significant input and output lags
Plots of autocorrt and crosscorrxt with significant
values identified with 'o'
Searching NEWSGROUP and ANSWERS using
greg narxnet
should help clear up questions.
PS: To answer your last question:
You have to use new values for Xi and Ai to continue.
Hope this clears our confusion.
Thank you for formally accepting my answer
Greg
  2 个评论
Machine Learning Enthusiast
My question was not answered clearly.The main focus was i am getting an error inline
forecastLoad = sim(net, testX')'
Greg Heath
Greg Heath 2017-12-29
编辑:Greg Heath 2017-12-29
See my revised answer above (You have to include new values for Xi, and Ai)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by