Why do i have NAN values in the confusion matrix only in the validation test?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
afef
el 27 de Jun. de 2017
Comentada: Ismail Cem Tüzün
el 20 de Feb. de 2023
I wanted to create neural network for binary classification for dataset with input matrix with size [9 981] and output matrix [1 981]and this is the code that i used
rng('default');
inputs = patientInputs;
targets = patientTargets;
x = mapminmax(inputs);
t=targets;
trainFcn = 'trainbr';
% Create a Pattern Recognition Network
hiddenLayerSize =10;
net = patternnet(hiddenLayerSize,trainFcn);
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;
net.performFcn = 'mse';
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotconfusion', 'plotroc'};
% Train the Network
net= configure(net,x,t);
[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);
% Recalculate Training, Validation and Test Performance
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 the Network
view(net)
At first i used the default trainFcn 'trainscg' then i tried to use 'trainbr' the accuracy improved but i got NAN values in the confusion matrix only in the validation test as you can see it here
Can anyone help me please?
0 comentarios
Respuesta aceptada
Greg Heath
el 28 de Jun. de 2017
MATLAB doesn't allow a validation set for trainbr because they think it isn't necessary for generalization.
Although they are correct, I have found in the literature that using BOTH trainbr and a validation set is better in most cases.
Although you cannot force trainbr to have validation set, I think you can work around it using trainlm and/or trainscg with regularization.
Hope this helps
Thank you for formally accepting my answer
Greg
PS: I don't remember details.
3 comentarios
muhammed shames
el 5 de Nov. de 2018
Hello sir can you explain me how you got rid of that NaN values ? Ive been working on it but it didnt work by just setting the max fail to 6 !
Ismail Cem Tüzün
el 20 de Feb. de 2023
when I set max fail to 6 even 10, it worked. I also re-assigned my epoch number. May be it also affected the system, not sure. Thanks for the information, btw
Más respuestas (0)
Ver también
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!