Neural Network Plotting Confusion Matrix
2 views (last 30 days)
Show older comments
Hi, i am currently using the neural network with Matlab and i want to plot a confusion matrix for the training, validation and testing stage. When i implement the confusion matrix with the code figure, plotconfusion(targets,outputs) - i only get the overall confusion matrix please can any one help me with this. Here is my full code.
inputs = totalnew;
targets = targetnew;
% Create a Pattern Recognition Network
hiddenLayerSize = 20;
net = patternnet(hiddenLayerSize);
% Choose Input and Output Pre/Post-Processing Functions
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
net.divideFcn = 'divideind';
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainInd = 1:700;
net.divideParam.valInd = 701:850;
net.divideParam.testInd = 851:1000;
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions
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
figure, plotconfusion(targets,outputs)
Please Help If You Can
0 Comments
Accepted Answer
Greg Heath
on 1 Jul 2013
Click on the plotconfusion button in the nntraintool window.
You have specified many net properties that are already defaults
... a waste of time and space.
Thank you for formally accepting my answer
Greg
0 Comments
More Answers (0)
See Also
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!