MATLAB: Probablity of outputs of binary classification in matlab

classificationDeep Learning Toolboxneural networkStatistics and Machine Learning Toolboxsvm

Hi
I have a binary classification problem and using neural network and SVM for it. So I choose a threshold (For instance 0.5) for output of neural network. If output is greater than 0.5 it belongs to class 1 and if it is smaller than 0.5 it belongs to class2. After training the network, for out sample data how can I calculate probability of outputs? For out sample data I use same criteria (0.5) and find the class out new these new data? Can we say if output of neural network is 1, the probability of belonging to class 1 (greater than 1 is class 1) is higher than for instance 0.55 ? ( I used tansig transfer function for output layer of neural network).
Another question: How can I find probability (or possibility) of belonging to each class in SVM?
I want find how much an out sample belong to a specific class. Can I do that? IS any function in Matlab for it?
Thanks.

Best Answer

If you use columns of eye(2) for targets, the outputs will be consistent (i.e., as N-> inf) estimates of the input-conditional posterior class probabilities provided the correct objective function is used.
Typically purelin, logsig and softmax are used as output transfer functions. Although MSE is reasonablr for the first two, crossentropy should be used for the latter.
In spite of being consistent estimates purelin does not enforce [0,1] and logsig does not enforce sum(estimates) = 1.
The conversion between the probability targets and estimates and the class indices is obtained using the functions ind2vec and vec2ind.
help ind2vec, doc ind2vec
nelp vec2ind, doc vec2ind
Hope this helps.
Thank you for formally accepting my answer
Greg
PS search using
greg patternnet vec2ind
greg patternnet ind2vec