Bad accuracy in the confusion matrix of neural network

3 次查看(过去 30 天)
Hi,i tried to create neural network for classification using nprtool i used the advanced script so i could normalize my data but in my cofusion matrix the accuracy is not that good.Tis is my code :
x =patientInputs;
t = patientTargets;
setdemorandstream (391418381)
trainFcn = 'trainscg';
hiddenLayerSize = 24;
net = patternnet(hiddenLayerSize);
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand';
net.divideMode = 'sample';
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.performFcn = 'crossentropy';
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotconfusion', 'plotroc'};
[net,tr] = train(net,x,t);
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
view(net)
And this is the confusion matrix that i got
Please can anyone help me what should i modify in my code to improve the accuracy of my neural network ?

回答(1 个)

orlem lima dos santos
编辑:orlem lima dos santos 2018-1-9
Hi, to obtain a better accuracy what I recommend to you is find the best hyperparameters (numbers node in the hidden layer, epochs and so on) of your network in order to do this you could go try and error or use algorithms like gridsearch (best option)
https://www.mathworks.com/matlabcentral/fileexchange/63132-grid-search-function-for-neural-networks.
This algorithm is going to give you the best hyperparameters given the inputs and targets.

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by