How to improve the performance of my neural network

3 views (last 30 days)
I am using matlab nprtool to train a neural network for classification. I have 367 data samples of 32 inputs and 2 classes. 207 belongs to class A and the remaining 160 belongs to the other class.I have changed the number of hidden layer many times but the one that produced a manageable result is 15. However the result is not satisfactory enough. 55 test sample was given to the trained net, 34 were classified correctly and 21 wrongly. I have a normalized dataset but i did not use it because i saw online that nprtool does normalization to all dataset by default. Please,how can i increase the performance of the network. Also, i changed training function from trainscg to trainlm but that has not helped. Below is the code generated by matlab.
%Input367_Decimal - input data.
target367 - target data.
inputs = Input367_Decimal;
targets = target367;
% Create a Pattern Recognition Network
hiddenLayerSize = 15;
net = patternnet(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 = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/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
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotregression', 'plotfit'};
% 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)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
figure, plotconfusion(targets,outputs)
%figure, ploterrhist(errors)
Any help will be much appreciated. Thanks
  5 Comments
Omotayo Asiru
Omotayo Asiru on 19 Sep 2016
Ok, i get your point now. I read about the classification learner app online but could not get any website to download it. Do u happen to know how I can download it ? maybe a link to its download. Thanks
Greg Heath
Greg Heath on 19 Sep 2016
Your initial post says number of number of hidden layers where you should have said number of hidden layer NODES.
HTH
Greg

Sign in to comment.

Answers (1)

Greg Heath
Greg Heath on 19 Sep 2016
The code you posted is too complicated for your first time out. See the examples in the documentation using the commands
help patternnet
doc patternnet
Then try the example data in
help nndatasets
doc nndatasets
Finally, you can search BOTH the NEWSGROUP and ANSWERS using
greg patternnet.
Hope this helps.
Thank you for formally accepting my answer
Greg
  1 Comment
Omotayo Asiru
Omotayo Asiru on 19 Sep 2016
Thanks for your response. I tried the examples(iris dataset for flower classification problem ,wine and cancer classification also) before i proceeded to d dataset for my work. However,those examples produced very good output,I got some that are almost 100% accurate. That is why i need a way to improve the performance of my network too. Maybe there is any default settings that i could change. Thanks

Sign in to comment.

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!