# Binary Classification _ problem with data structure

2 views (last 30 days)
afef on 27 Jun 2017
Commented: afef on 28 Jun 2017
Hi, i want to create neural network for binary classification so when i read in matlab doc for patternet that Classification problems involving only two classes can be represented using either format. The targets can consist of either scalar 1/0 elements or two-element vectors, with one element being 1 and the other element being 0.(link= https://www.mathworks.com/help/nnet/gs/classify-patterns-with-a-neural-network.html) so i tried to set each scalar target value to either 0 or 1 but in the confusion matrix i got NAN values for the second class
[ I N ] = [ 9 981 ]
[ O N ] = [ 1 981 ]
And this is the code
rng('default');
x = patientInputs;
t = patientTargets ;
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize =10;
net = patternnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
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'; % Cross-Entropy
% 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
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
% View the Network
view(net) i don't know why? can anyone tell me please?

Greg Heath on 28 Jun 2017
There might be a caveat in the confusion matrix code that only accepts {0,1} 1-d outputs.
check it out.
Greg
##### 2 CommentsShowHide 1 older comment
afef on 28 Jun 2017
And i want to know when you said 1-d outputs. 'd' referes to what ??