Sensitivity and Specificity are usually defined for a binary classification problem.
Based on your code it looks like you are dealing with 4 classes.
In that case, you could apply a one vs. all approach, i.e. calculate the sensitivity and specificity for each class. For class0 this would be:
- TP of class0 are all class0 samples classified asclass0.
- TN of class0 are all non-class0 samples classified as non-class0.
- FP of class0 are all non-class0 samples classified as class0.
- FN of class0 are all class0 samples not classified as class0.