MATLAB: How does a neural network assign outputs – is there an intrinsic threshold value

neural networkneural networks

I have a neural network in MATLAB that assigns output to either yes or no (1 or 0) target values. The numbers I get for True Positives, False Positives, True Negatives and False Negatives in the confusion plot are different to the corresponding numbers if I calculate them in the way I would expect they were calculated. I have tried this on a dataset consisting entirely of training data in order to avoid any problems with random data ordering.
Output is a 2xR matrix where R is total records. Each entry is between 0 and 1. Let the output values for record i be O(1,i) and O(2,i).
My first intuition was that if O(1,i) > O(2,i) output will be assigned to class 1, and if O(2,i) > O(1,i) output will be assigned to class 2.
Apparently not so.
My second attempt ignores the output value of class 2, and assigns to class 1 if O(1,i) > 0.5 and class 2 if O(1,i) < 0.5.
Also not the case – though gave an answer close to my first attempt.
Does anyone know how the network actually determines which class the output belongs to? Would be so grateful if you could tell me.

Best Answer

In general, the assigned class is the one associated with the largest output.
Outputs do NOT have to have any of the following properties for a class-conditional posterior probability
0 <= y(i) <= 1, 1 <= i <= c
sum(y) = 1
Therefore, classifiers could have a variety of output transfer functions.
However, for MATLAB's confusion function,
From doc confusion:
targets:
c-by-N matrix, where each column vector contains a single 1 value, with all other elements 0. The index of the 1 indicates which of c categories that vector represents.
outputs:
c-by-N matrix, where each column contains values in the range [0,1]. The index of the largest element in the column indicates which of c categories that vector represents.
Note that the [0,1] output restriction eliminates classifiers with purelin transfer functions.
Also see
help confusion
Hope this helps
Thank you for formally accepting my answer
Greg