NARX Neural Network test on new test set?

2 ビュー (過去 30 日間)
Machine Learning Enthusiast
Machine Learning Enthusiast 2017 年 9 月 12 日
編集済み: Greg Heath 2017 年 12 月 29 日
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 日
Searc the NEWSGROUP and ANSWERS using
greg narxnet
Hope this helps.
Greg

サインインしてコメントする。

回答 (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
Machine Learning Enthusiast 2017 年 9 月 13 日
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 Center および File ExchangeSequence 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