Neural Network Plotting Confusion Matrix

3 次查看(过去 30 天)
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

采纳的回答

Greg Heath
Greg Heath 2013-7-1
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 个)

类别

Help CenterFile Exchange 中查找有关 Pattern Recognition and Classification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by