NARX Neural Network test on new test set?

1 visualizzazione (ultimi 30 giorni)
Machine Learning Enthusiast
Commentato: Greg Heath il 3 Giu 2017
After training NAREX net.I want to test the model on independent test set "testX'".But it returns me an error.I am testing the model by forecastLoad = sim(net, testX')'.
%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);
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 Commento
Greg Heath
Greg Heath il 3 Giu 2017
Whenever you post code, it is wise to use MATLAB example data obtained from the commands
help nndatasets
and
doc nndatasets.
Hope this helps.
Greg

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by