NARX Neural Network test on new test set?
조회 수: 1 (최근 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
답변 (1개)
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
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 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!