MATLAB: Matlab Neural Net: Classifying Numerically Related Classes.

machine learningneural networknprtool

Let’s say we have dataset of people's Heights and Weights as inputs and the T-Shirt size which they wear as outputs for example: XL, L, M, S, XS. I am using Matlab nprtool's default configuration for such problems, i.e. One-vs-All classification model with trainscg for traning & mse for performance evaluation.
The problem I am facing is that classification results are not very good. One obvious reason is that there is no way the neural net can explicitly judge that XL is closer to L than XS. In current setup, XL<->XS misclassification is considered same as XL<->L misclassification. Whereas XL<->L misclassification is not as problematic as XL<->XS.
I tried replacing XL, L, M, S and XS as numbers for example, XL=5, L=4, M=3, S=2 & XS=1 and used curve fitting tool which performed exceptionally well. But unfortunately I cannot use this model because I need output in terms of probabilities rather than concrete predictions. For example what I want is that I should be able to give height and weight and get probability for each of the classes (XL, L, M, S & XS).
I believe there should be a way to customize performance function. I would like to map my output classes on to numbers, multiply them with their probabilities and get a final output. For this output I will use mse for performance evaluation the way it is done in the context of curve fitting. My question is how do I do that in Matlab? Please note that I am fairly new to Matlab's nprtool so use layman type language rather than using nprtool's jargon.

Best Answer

There is no need to take the sequential nature of the output into account.
Just use 5-dimensional unit vectors with a single unit component to represent the class targets. The relationship between class indices (1:5) and target vectors eye(5)is
classindices = vec2ind(target)
and
target = ind2vec(classindices)
If you minimize mean-square-error or cross-entropy with purelin, logsig, or softmax output transfer functions, in spite of the fact the range [ 0 1] and normalization constraints sum(output) = ones(1,N) may not hold, the resulting outputs will be consistent estimates of the class posterior probabilities, conditional on the input.
If you use the logsig output transfer function, output./sum(output) will satisfy the constraints.
Probability relationships between classes will be displayed in the confusion matrices.
Hope this helps.
Thank you for formally accepting my answer
Greg