Neural network (fitnet) and data decomposition?

3 views (last 30 days)
Can you help me to rectify these code, I used fitnet to predict future index. I need to decompose the data only to training and test:
inputs = P';
targets = T';
% Create a Fitting Network
net = fitnet(hiddenLayerSize);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'divideblock'; % Divide data into two block (the first 80% of data sample for train and the rest for test)
net.divideMode = 'sample';
% Divide up every sample
net.divideParam.trainRatio = 80/100;
% net.divideParam.valRatio = 0;
net.divideParam.testRatio = 20/100;
% For help on training function 'trainlm' type: help trainlm
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
MSEgoal = 0.001
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% Recalculate Training, Validation and Test Performance
trainTargets = targets .* tr.trainMask{1};
% valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
% valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)

Accepted Answer

Greg Heath
Greg Heath on 22 Jan 2016
The training and test indices are given in tr. Type, without semicolon
tr = tr
to see what info is in tr.
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (1)

CH PH
CH PH on 31 Jan 2021
no result

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!