NARX Neural Network test on new test set?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Greg Heath
le 13 Sep 2017
Modifié(e) : Greg Heath
le 29 Déc 2017
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 commentaires
Greg Heath
le 29 Déc 2017
Modifié(e) : Greg Heath
le 29 Déc 2017
See my revised answer above (You have to include new values for Xi, and Ai)
Voir également
Catégories
En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!