The ground truth data must contain class label information. As the ground truth is in the form of a matrix, you can reshape it to a vector to obtain vector of true class labels.
DataVector = reshape(hsData,[M*N C]);
labels=[5, 11, 18, 20, 22, 23, 25];
Locs = find(gtVector==labels(i));
class_info = gtVector(gtLocs);
data_info = DataVector(gtLocs,:);
Now you can use 'class_info' and 'data_info' for classification.
For classification, you can refer to the examples in:
- fitcknn function for K- neareset neighbour classifier
After obtaining your classification results, you can refer:
- confusionmat, confusionchart for preparing the confusion matrix.
- For computing F1 score for a specific class, you need to pre-process the true and predicted class label vectors. In this step, compare these vectors with a desired class label (say 23) and convert the multiclass true and predicted class label vectors to binary vectors. And then, you can refer this for class specific performance measures.
"confusionmatStats(group,grouphat)" is one of the several submissions in MATLAB File Exchange on MATLAB Central which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. Feel free to contact the author of this submission directly for specific questions about the implementation.